
/****************************************************************************
 * 0. Housekeeping
 ****************************************************************************/
clear all
set more off

global mainpath "/Users/petterhallqvist/Desktop/tore_ellingsen/crowding_multiple_games_combined"
cd "$mainpath"


/****************************************************************************
 * 1. Analysis Section
 ****************************************************************************/



								*-----------------*
								* mainpath PROGRAM  *
								*-----------------*

capt prog drop ttesttab
program ttesttab, rclass
args `varlist'
ttest `1' == `2', unp
return list

matrix B = (r(N_1), r(N_2), r(mu_1), r(mu_2), r(mu_1) - r(mu_2), r(p_l))
matrix colnames B = n_1 n_2 mu_1 mu_2 diff p_l

local label: di "`: var label  `1' ' - `: var label `2'' "
mat rownames B = "`label'"
matmap B A, map(round(@, 0.001))
mat list B

end	
 
global always2 "booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("n_1(fmt(%9.1fc)) n_2(fmt(%9.1fc)) mu_1(fmt(%9.1fc)) mu_2(fmt(%9.1fc)) diff(fmt(%9.1fc)) p_l(fmt(%9.1fc))" ) fragment nolines nogaps nomtitles nocons label "

						 *-------------------*
						 * HYPOTESIS TESTING *
						 *-------------------*
						
*log using "$logfile/3. Analysis", replace 
				
* SOCIAL APPROPRIATENESS
forvalue i =5 (2) 7 {
use "$mainpath/MultiplesGamesElicitation_Social_cleaned.dta", clear 

							*** DICTATOR GAME ***
	
	*A) Hypotheses and Tests: Comparing across questions situations
	
	forvalues i= 1/3 {
		local p = `i'-1
		local t1 = `i'+ 2
		local t5 = `i'+ 11
		
		label var StandardDG_`i'_n "St. DG (`p')"
		label var DGtake1_`t1'_n "DG take 1 (`p')"
		label var DGtake5_`t5'_n "DG take 5 (`p')"
		label var DGQuiz_`i'_n "DG Quiz (`p')"
		label var DGProduction_`i'_n "DG Production (`p')"
	
	if `i' == 1 {
	local varlist StandardDG_`i'_n DGtake1_`t1'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers.tex", replace $always2 
	eststo clear
	
	local varlist StandardDG_`i'_n DGtake5_`t5'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers.tex", append $always2 
	eststo clear
	
	local varlist StandardDG_`i'_n DGQuiz_`i'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers.tex", append $always2 
	eststo clear
	
	local varlist StandardDG_`i'_n DGProduction_`i'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers.tex", append $always2 
	eststo clear
	}
	
	if `i' > 1 {
	local varlist StandardDG_`i'_n DGtake1_`t1'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers.tex", append $always2 
	eststo clear
	
	local varlist StandardDG_`i'_n DGtake5_`t5'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers.tex", append $always2 
	eststo clear
	
	local varlist StandardDG_`i'_n DGQuiz_`i'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers.tex", append $always2 
	eststo clear
	
	local varlist StandardDG_`i'_n DGProduction_`i'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers.tex", append $always2 
	eststo clear
	}
	
	}
	
	// DG with Exit option 
	ttest DGoutsideoption9_2_n == DGoutsideoption9_1_n, unp 
	local varlist DGoutsideoption9_2_n  DGoutsideoption9_1_n
	label var  DGoutsideoption9_1_n  "DG ex. (exit)"
	label var  DGoutsideoption9_2_n  "DG ex. (give 1)"
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers.tex", append $always2 
	eststo clear

	
	// DG information (treatment Y)
	ttest DWKtreatment_2_n == DWKtreatment_4_n, unp 
	local varlist DWKtreatment_2_n DWKtreatment_4_n
	label var  DWKtreatment_4_n  "DG info (Y)"
	label var  DWKtreatment_2_n   "DG no info (Y)"
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers.tex", append $always2 
	eststo clear
	
	// DG information (treatment X)
	ttest DWKtreatment_3_n == DWKtreatment_1_n, unp 
	local varlist DWKtreatment_3_n DWKtreatment_1_n
	label var  DWKtreatment_3_n  "DG info (X)"
	label var  DWKtreatment_1_n  "DG no info (X)"
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers.tex", append $always2 
	eststo clear

	*B) Hypotheses and Tests: Gender differences
	encode Sex, gen(gender) //
	replace gender =0 if gender ==2
	label define gender 0 "Male" 1 "Female", replace
	label val gender gender 
	
	local varlist StandardDG_1_n StandardDG_2_n StandardDG_3_n StandardDG_4_n StandardDG_5_n StandardDG_6_n StandardDG_7_n StandardDG_8_n StandardDG_9_n StandardDG_10_n StandardDG_11_n DGoutsideoption9_1_n DGoutsideoption9_2_n DGoutsideoption9_3_n DGoutsideoption9_4_n DGoutsideoption9_5_n DGoutsideoption9_6_n DGoutsideoption9_7_n DGoutsideoption9_8_n DGoutsideoption9_9_n DGoutsideoption9_10_n DGoutsideoption9_11_n DGoutsideoption9_12_n DGtake1_1_n DGtake1_2_n DGtake1_3_n DGtake1_4_n DGtake1_5_n DGtake1_6_n DGtake1_7_n DGtake1_8_n DGtake1_9_n DGtake1_10_n DGtake1_11_n DGtake1_12_n DGtake1_13_n DGtake5_1_n DGtake5_2_n DGtake5_3_n DGtake5_4_n DGtake5_5_n DGtake5_6_n DGtake5_7_n DGtake5_8_n DGtake5_9_n DGtake5_10_n DGtake5_11_n DGtake5_12_n DGtake5_13_n DGtake5_14_n DGtake5_15_n DGtake5_16_n DGtake5_17_n DGtake5_18_n DGtake5_19_n DGtake5_20_n DGtake5_21_n DGQuiz_1_n DGQuiz_2_n DGQuiz_3_n DGQuiz_4_n DGQuiz_5_n DGQuiz_6_n DGQuiz_7_n DGQuiz_8_n DGQuiz_9_n DGQuiz_10_n DGQuiz_11_n DGProduction_1_n DGProduction_2_n DGProduction_3_n DGProduction_4_n DGProduction_5_n DGProduction_6_n DGProduction_7_n DGProduction_8_n DGProduction_9_n DGProduction_10_n  DGProduction_11_n 
	
	foreach var in `varlist' {	
		egen mode_`var' = mode(`var')
		gen correct_`var' =  (`var' == mode_`var')
		replace correct_`var' = . if `var'  ==.
		order mode_`var' correct_`var', after (`var')
		
				}
	
	forvalues i=1/11 {
		local p=`i'-1
		label var correct_StandardDG_`i'_n "St. DG (`p')"
	    label var correct_DGProduction_`i'_n "Production DG (`p')"
		label var correct_DGQuiz_`i'_n "Quiz DG (`p')"
	}
	
	forvalues i=1/12 {
		local p=`i'-1
		label var correct_DGoutsideoption9_`i'_n "DG exit (`p')"
		
	}
	
	forvalues i=1/13 {
		local p=`i'-3
		label var correct_DGtake1_`i'_n "DG take 1 (`p')"
		}
		
	
	
	forvalues i=1/21 {
		local p=`i'-11
		label var correct_DGtake5_`i'_n "DG take 5 (`p')"
	}
	
		local varlist1 correct_StandardDG_1_n correct_StandardDG_2_n correct_StandardDG_3_n correct_StandardDG_4_n correct_StandardDG_5_n correct_StandardDG_6_n correct_StandardDG_7_n correct_StandardDG_8_n correct_StandardDG_9_n correct_StandardDG_10_n correct_StandardDG_11_n correct_DGoutsideoption9_1_n correct_DGoutsideoption9_2_n correct_DGoutsideoption9_3_n correct_DGoutsideoption9_4_n correct_DGoutsideoption9_5_n correct_DGoutsideoption9_6_n correct_DGoutsideoption9_7_n correct_DGoutsideoption9_8_n correct_DGoutsideoption9_9_n correct_DGoutsideoption9_10_n correct_DGoutsideoption9_11_n correct_DGoutsideoption9_12_n correct_DGtake1_1_n correct_DGtake1_2_n correct_DGtake1_3_n correct_DGtake1_4_n correct_DGtake1_5_n correct_DGtake1_6_n correct_DGtake1_7_n correct_DGtake1_8_n correct_DGtake1_9_n correct_DGtake1_10_n correct_DGtake1_11_n correct_DGtake1_12_n correct_DGtake1_13_n 
		
		estpost ttest `varlist1', by(gender)
		esttab using "$mainpath/table_DG_gender1.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p_l(fmt(4))") ///
		collabels("Obs." "Mean (men)" "Mean (women)" "Diff." "P-value (H0: diff =0, H1: diff<0)") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		refcat( correct_StandardDG_1_n  "\textbf{Standard DG}" correct_DGoutsideoption9_1_n "\vspace{0.1em} \\ \textbf{DG with exit option}" ///
		correct_DGtake1_1_n "\vspace{0.1em} \\ \textbf{DG take 1}" , nolabel) ///
		replace 

		
		local varlist2 correct_DGtake5_1_n correct_DGtake5_2_n correct_DGtake5_3_n correct_DGtake5_4_n correct_DGtake5_5_n correct_DGtake5_6_n correct_DGtake5_7_n correct_DGtake5_8_n correct_DGtake5_9_n correct_DGtake5_10_n correct_DGtake5_11_n correct_DGtake5_12_n correct_DGtake5_13_n correct_DGtake5_14_n correct_DGtake5_15_n correct_DGtake5_16_n correct_DGtake5_17_n correct_DGtake5_18_n correct_DGtake5_19_n correct_DGtake5_20_n correct_DGtake5_21_n correct_DGQuiz_1_n correct_DGQuiz_2_n correct_DGQuiz_3_n correct_DGQuiz_4_n correct_DGQuiz_5_n correct_DGQuiz_6_n correct_DGQuiz_7_n correct_DGQuiz_8_n correct_DGQuiz_9_n correct_DGQuiz_10_n correct_DGQuiz_11_n correct_DGProduction_1_n correct_DGProduction_2_n correct_DGProduction_3_n correct_DGProduction_4_n correct_DGProduction_5_n correct_DGProduction_6_n correct_DGProduction_7_n correct_DGProduction_8_n correct_DGProduction_9_n correct_DGProduction_10_n  correct_DGProduction_11_n 
			
		
		estpost ttest `varlist2', by(gender)
		esttab using "$mainpath/table_DG_gender2.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p_l(fmt(4))") ///
		collabels("Obs." "Mean (men)" "Mean (women)" "Diff." "P-value (H0: diff =0, H1: diff<0)") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		refcat( correct_DGtake5_1_n "\vspace{0.1em} \\ \textbf{DG take 5}" ///
		correct_DGQuiz_1_n "\vspace{0.1em} \\ \textbf{DG quiz}" correct_DGProduction_1_n "\vspace{0.1em} \\ \textbf{DG production}", nolabel) ///
		replace 

		
	* C) Order effects
	
	*1) Hypotheses and Tests: Order effects -> compare (i) average rating by subjects who saw that game as the first game in the whole experiment, with (ii) average rating by all other subjects (i.e. all subjects who did not see that game as the first game in the whole experiment), under the same mode of appropriateness.
	
	gen FL_35_DO_first= substr(FL_35_DO, 1, 10) 
	gen FL_55_DO_first= substr(FL_55_DO, 1, 10) 
	gen FL_75_DO_first= substr(FL_75_DO, 1, 10) 
	gen FL_68_DO_first= substr(FL_68_DO, 1, 10) 
	
	gen DGwitouthistory_first = 1 if strpos(FL_35_DO_first, "DG(without") | strpos(FL_55_DO_first, "DG(without") | strpos(FL_75_DO_first, "DG(without") | strpos(FL_68_DO_first, "DG(without")
	replace DGwitouthistory_first = 0 if DGwitouthistory_first==.
	
	gen DG_standard_first = 1 if strpos(DGwithouthistory_DO, "Standard DG") & DGwitouthistory_first == 1
		replace  DG_standard_first=0 if DG_standard_first==.
		label var DG_standard_first "St. DG first"
	
	gen DG_take1_first = 1 if strpos(DGwithouthistory_DO, "DG take 1") & DGwitouthistory_first == 1
		replace  DG_take1_first=0 if DG_take1_first==.
		label var DG_take1_first "DG take 1 first"
	
	gen DG_take5_first = 1 if strpos(DGwithouthistory_DO, "DG take 5") & DGwitouthistory_first == 1
		replace  DG_take5_first=0 if  DG_take5_first ==. 
		label var DG_take5_first "DG take 5 first"
		
	gen DG_option9_first = 1 if strpos(DGwithouthistory_DO, "DG outside option $9") & DGwitouthistory_first == 1
		replace  DG_option9_first=0 if DG_option9_first==.
		label var DG_option9_first "DG exit opt. first"
	
	gen DGproquiz_first = 1 if strpos(FL_35_DO_first, "DGQuiz&Pro") 
	
	gen DG_production_first = 1 if strpos(DGQuizProduction_DO, "DG Production") & DGproquiz_first ==1
		replace  DG_production_first=0 if DG_production_first==.
		label var DG_production_first "DG prod. first"
	
	gen DG_quiz_first = 1 if strpos(DGQuizProduction_DO, "DG Quiz") & DGproquiz_first  == 1
		replace  DG_quiz_first=0 if DG_quiz_first==. 
		label var DG_quiz_first "DG quiz first"
	
	forvalues i=1/11 {
		local p=`i'-1
		label var StandardDG_`i'_n "St. DG (`p')"
	    label var DGProduction_`i'_n "Production DG (`p')"
		label var DGQuiz_`i'_n "Quiz DG (`p')"
	}
	
	forvalues i=1/12 {
		local p=`i'-1
		label var DGoutsideoption9_`i'_n "DG exit (`p')"
		
	}
	
	forvalues i=1/13 {
		local p=`i'-3
		label var DGtake1_`i'_n "DG take 1 (`p')"
		}
		
	
	
	forvalues i=1/21 {
		local p=`i'-11
		label var DGtake5_`i'_n "DG take 5 (`p')"
	}	

	local varlist1 StandardDG_1_n StandardDG_2_n StandardDG_3_n StandardDG_4_n StandardDG_5_n StandardDG_6_n StandardDG_7_n StandardDG_8_n StandardDG_9_n StandardDG_10_n StandardDG_11_n 
	foreach var in `varlist1'{
			ttest `var' , by(DG_standard_first)
	}
	estpost ttest `varlist1', by(DG_standard_first)
	esttab using "$mainpath/table_DG_standard_fisrt.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p(fmt(4))") ///
		collabels("Obs." "Mean (others)" "Mean (seen fisrt)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		replace
	
	local varlist2 DGoutsideoption9_1_n DGoutsideoption9_2_n DGoutsideoption9_3_n DGoutsideoption9_4_n DGoutsideoption9_5_n DGoutsideoption9_6_n DGoutsideoption9_7_n DGoutsideoption9_8_n DGoutsideoption9_9_n DGoutsideoption9_10_n DGoutsideoption9_11_n DGoutsideoption9_12_n 
	foreach var in `varlist2' {
		ttest `var' , by(DG_option9_first)
	}
	estpost ttest `varlist2', by(DG_option9_first)
	esttab using "$mainpath/table_DG_option9_first.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p(fmt(4))") ///
		collabels("Obs." "Mean (others)" "Mean (seen fisrt)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		replace
		
	local varlist3 DGtake1_1_n DGtake1_2_n DGtake1_3_n DGtake1_4_n DGtake1_5_n DGtake1_6_n DGtake1_7_n DGtake1_8_n DGtake1_9_n DGtake1_10_n DGtake1_11_n DGtake1_12_n DGtake1_13_n 
	foreach var in `varlist3' {
		ttest `var' , by(DG_take1_first)
	}
	estpost ttest `varlist3', by(DG_take1_first)
	esttab using "$mainpath/table_DG_take1_first.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p_l(fmt(4))") ///
		collabels("Obs." "Mean (others)" "Mean (seen fisrt)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		replace
	
	local varlist4 DGtake5_1_n DGtake5_2_n DGtake5_3_n DGtake5_4_n DGtake5_5_n DGtake5_6_n DGtake5_7_n DGtake5_8_n DGtake5_9_n DGtake5_10_n DGtake5_11_n DGtake5_12_n DGtake5_13_n DGtake5_14_n DGtake5_15_n DGtake5_16_n DGtake5_17_n DGtake5_18_n DGtake5_19_n DGtake5_20_n DGtake5_21_n 
	foreach var in `varlist4'{
		ttest `var' , by(DG_take5_first)
	}
	estpost ttest `varlist4', by(DG_take5_first)
	esttab using "$mainpath/table_DG_take5_first.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p_l(fmt(4))") ///
		collabels("Obs." "Mean (others)" "Mean (seen fisrt)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		replace


	local varlist5 DGProduction_1_n DGProduction_2_n DGProduction_4_n DGProduction_5_n DGProduction_6_n DGProduction_7_n DGProduction_8_n DGProduction_9_n DGProduction_10_n DGProduction_11_n 
	foreach var in `varlist5' {
		ttest `var' , by(DG_production_first )
	}
	estpost ttest `varlist5', by(DG_production_first)
	esttab using "$mainpath/table_DG_production_first.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p_l(fmt(4))") ///
		collabels("Obs." "Mean (others)" "Mean (seen fisrt)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		replace
	

	
	local varlist6  DGQuiz_1_n DGQuiz_2_n DGQuiz_3_n DGQuiz_4_n DGQuiz_5_n DGQuiz_6_n DGQuiz_8_n DGQuiz_9_n DGQuiz_10_n DGQuiz_11_n
	foreach var in `varlist6' {
		ttest `var' , by(DG_quiz_first)
	}
	
	estpost ttest `varlist6', by(DG_quiz_first)
	esttab using "$mainpath/table_DG_quiz_first.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p_l(fmt(4))") ///
		collabels("Obs." "Mean (others)" "Mean (seen fisrt)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		replace

	*2) 
			
	// DG stabdard
	local varlist1 StandardDG_1_n StandardDG_2_n StandardDG_3_n StandardDG_4_n StandardDG_5_n StandardDG_6_n StandardDG_7_n StandardDG_8_n StandardDG_9_n StandardDG_10_n StandardDG_11_n 
	eststo: reg DG_standard_first `varlist1'
	esttab using "$mainpath/table_DG_standard_OE.tex", se scalars(F p) wide label replace
	eststo clear 
	
	// DG with exit option
	local varlist2 DGoutsideoption9_1_n DGoutsideoption9_2_n DGoutsideoption9_3_n DGoutsideoption9_4_n DGoutsideoption9_5_n DGoutsideoption9_6_n DGoutsideoption9_7_n DGoutsideoption9_8_n DGoutsideoption9_9_n DGoutsideoption9_10_n DGoutsideoption9_11_n DGoutsideoption9_12_n 
	eststo: reg DG_option9_first `varlist2'
	esttab using "$mainpath/table_DG_option9_OE.tex", se scalars(F p) wide label replace
	eststo clear 

	// DG with take 1 optioin	
	local varlist3 DGtake1_1_n DGtake1_2_n DGtake1_3_n DGtake1_4_n DGtake1_5_n DGtake1_6_n DGtake1_7_n DGtake1_8_n DGtake1_9_n DGtake1_10_n DGtake1_11_n DGtake1_12_n DGtake1_13_n 
	eststo: reg DG_take1_first `varlist3'
	eststo: esttab using "$mainpath/table_DG_take1_OE.tex", se scalars(F p) wide label replace
	eststo clear 

	// DG with take 5 option
	local varlist4 DGtake5_1_n DGtake5_2_n DGtake5_3_n DGtake5_4_n DGtake5_5_n DGtake5_6_n DGtake5_7_n DGtake5_8_n DGtake5_9_n DGtake5_10_n DGtake5_11_n DGtake5_12_n DGtake5_13_n DGtake5_14_n DGtake5_15_n DGtake5_16_n DGtake5_17_n DGtake5_18_n DGtake5_19_n DGtake5_20_n DGtake5_21_n 
	eststo: reg DG_take5_first `varlist4'
	esttab using "$mainpath/table_DG_take5_OE.tex", se scalars(F p) wide label replace
	eststo clear 

	// DG with production
	local varlist5 DGProduction_1_n DGProduction_2_n DGProduction_4_n DGProduction_5_n DGProduction_6_n DGProduction_7_n DGProduction_8_n DGProduction_9_n DGProduction_10_n DGProduction_11_n 
	eststo: reg DG_production_first `varlist5'
	esttab using "$mainpath/table_DG_production_OE.tex", se scalars(F p) wide label replace
	eststo clear 


	// DG with quiz
	local varlist6  DGQuiz_1_n DGQuiz_2_n DGQuiz_3_n DGQuiz_4_n DGQuiz_5_n DGQuiz_6_n DGQuiz_8_n DGQuiz_9_n DGQuiz_10_n DGQuiz_11_n
	reg DG_quiz_first `varlist6' 
	 esttab using "$mainpath/table_DG_quiz_OE.tex", se scalars(F p) wide label replace
	 eststo clear 

********************************************************************************

* PERSONAL APPROPRIATENESS
use "$mainpath/MultiplesGamesElicitation_Pers_cleaned.dta", clear 

							*** DICTATOR GAME ***
	
	*A)  Hypotheses and Tests: Comparing across questions situations
	
	forvalues i= 1/3 {
		local p = `i'-1
		local t1 = `i'+ 2
		local t5 = `i'+ 11
		
		label var StandardDG_`i'_n "St. DG (`p')"
		label var DGtake1_`t1'_n "DG take 1 (`p')"
		label var DGtake5_`t5'_n "DG take 5 (`p')"
		label var DGQuiz_`i'_n "DG Quiz (`p')"
		label var DGProduction_`i'_n "DG Production (`p')"
	
	if `i' == 1 {
	local varlist StandardDG_`i'_n DGtake1_`t1'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers_personal.tex", replace $always2 
	eststo clear
	
	local varlist StandardDG_`i'_n DGtake5_`t5'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers_personal.tex", append $always2 
	eststo clear
	
	local varlist StandardDG_`i'_n DGQuiz_`i'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers_personal.tex", append $always2 
	eststo clear
	
	local varlist StandardDG_`i'_n DGProduction_`i'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers_personal.tex", append $always2 
	eststo clear
	}
	
	if `i' > 1 {
	local varlist StandardDG_`i'_n DGtake1_`t1'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers_personal.tex", append $always2 
	eststo clear
	
	local varlist StandardDG_`i'_n DGtake5_`t5'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers_personal.tex", append $always2 
	eststo clear
	
	local varlist StandardDG_`i'_n DGQuiz_`i'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers_personal.tex", append $always2 
	eststo clear
	
	local varlist StandardDG_`i'_n DGProduction_`i'_n
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers_personal.tex", append $always2 
	eststo clear
	}
	
	}
	
	// DG with Exit option 
	ttest DGoutsideoption9_2_n == DGoutsideoption9_1_n, unp 
	local varlist DGoutsideoption9_2_n  DGoutsideoption9_1_n
	label var  DGoutsideoption9_1_n  "DG ex. (exit)"
	label var  DGoutsideoption9_2_n  "DG ex. (give 1)"
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers_personal.tex", append $always2 
	eststo clear

		// DG information (treatment Y)
	ttest DWKtreatment_2_n == DWKtreatment_4_n, unp 
	local varlist DWKtreatment_2_n DWKtreatment_4_n
	label var  DWKtreatment_4_n  "DG info (Y)"
	label var  DWKtreatment_2_n   "DG no info (Y)"
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers_personal.tex", append $always2 
	eststo clear
	
	// DG information (treatment X)
	ttest DWKtreatment_3_n == DWKtreatment_1_n, unp 
	local varlist DWKtreatment_3_n DWKtreatment_1_n
	label var  DWKtreatment_3_n  "DG info (X)"
	label var  DWKtreatment_1_n  "DG no info (X)"
	ttesttab `varlist'
	esttab matrix(A) using "$mainpath/table_DG_standardvsothers_personal.tex", append $always2 
	eststo clear
	
	*B)  Hypotheses and Tests: Gender differences
	encode Sex, gen(gender) //
	replace gender =0 if gender ==2
	label define gender 0 "Male" 1 "Female", replace
	label val gender gender 
	
	local varlist StandardDG_1_n StandardDG_2_n StandardDG_3_n StandardDG_4_n StandardDG_5_n StandardDG_6_n StandardDG_7_n StandardDG_8_n StandardDG_9_n StandardDG_10_n StandardDG_11_n DGoutsideoption9_1_n DGoutsideoption9_2_n DGoutsideoption9_3_n DGoutsideoption9_4_n DGoutsideoption9_5_n DGoutsideoption9_6_n DGoutsideoption9_7_n DGoutsideoption9_8_n DGoutsideoption9_9_n DGoutsideoption9_10_n DGoutsideoption9_11_n DGoutsideoption9_12_n DGtake1_1_n DGtake1_2_n DGtake1_3_n DGtake1_4_n DGtake1_5_n DGtake1_6_n DGtake1_7_n DGtake1_8_n DGtake1_9_n DGtake1_10_n DGtake1_11_n DGtake1_12_n DGtake1_13_n DGtake5_1_n DGtake5_2_n DGtake5_3_n DGtake5_4_n DGtake5_5_n DGtake5_6_n DGtake5_7_n DGtake5_8_n DGtake5_9_n DGtake5_10_n DGtake5_11_n DGtake5_12_n DGtake5_13_n DGtake5_14_n DGtake5_15_n DGtake5_16_n DGtake5_17_n DGtake5_18_n DGtake5_19_n DGtake5_20_n DGtake5_21_n DGQuiz_1_n DGQuiz_2_n DGQuiz_3_n DGQuiz_4_n DGQuiz_5_n DGQuiz_6_n DGQuiz_7_n DGQuiz_8_n DGQuiz_9_n DGQuiz_10_n DGQuiz_11_n DGProduction_1_n DGProduction_2_n DGProduction_3_n DGProduction_4_n DGProduction_5_n DGProduction_6_n DGProduction_7_n DGProduction_8_n DGProduction_9_n DGProduction_10_n  DGProduction_11_n 
	
	foreach var in `varlist' {	
		egen mode_`var' = mode(`var')
		gen correct_`var' =  (`var' == mode_`var')
		replace correct_`var' = . if `var'  ==.
		order mode_`var' correct_`var', after (`var')
		
				}
	
	forvalues i=1/11 {
		local p=`i'-1
		label var correct_StandardDG_`i'_n "St. DG (`p')"
	    label var correct_DGProduction_`i'_n "Production DG (`p')"
		label var correct_DGQuiz_`i'_n "Quiz DG (`p')"
	}
	
	forvalues i=1/12 {
		local p=`i'-1
		label var correct_DGoutsideoption9_`i'_n "DG exit (`p')"
		
	}
	
	forvalues i=1/13 {
		local p=`i'-3
		label var correct_DGtake1_`i'_n "DG take 1 (`p')"
		}
		
	
	
	forvalues i=1/21 {
		local p=`i'-11
		label var correct_DGtake5_`i'_n "DG take 5 (`p')"
	}
	
		local varlist1 correct_StandardDG_1_n correct_StandardDG_2_n correct_StandardDG_3_n correct_StandardDG_4_n correct_StandardDG_5_n correct_StandardDG_6_n correct_StandardDG_7_n correct_StandardDG_8_n correct_StandardDG_9_n correct_StandardDG_10_n correct_StandardDG_11_n correct_DGoutsideoption9_1_n correct_DGoutsideoption9_2_n correct_DGoutsideoption9_3_n correct_DGoutsideoption9_4_n correct_DGoutsideoption9_5_n correct_DGoutsideoption9_6_n correct_DGoutsideoption9_7_n correct_DGoutsideoption9_8_n correct_DGoutsideoption9_9_n correct_DGoutsideoption9_10_n correct_DGoutsideoption9_11_n correct_DGoutsideoption9_12_n correct_DGtake1_1_n correct_DGtake1_2_n correct_DGtake1_3_n correct_DGtake1_4_n correct_DGtake1_5_n correct_DGtake1_6_n correct_DGtake1_7_n correct_DGtake1_8_n correct_DGtake1_9_n correct_DGtake1_10_n correct_DGtake1_11_n correct_DGtake1_12_n correct_DGtake1_13_n 
		
		estpost ttest `varlist1', by(gender)
		esttab using "$mainpath/table_DG_gender1_personal.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p(fmt(4))") ///
		collabels("Obs." "Mean (men)" "Mean (women)" "Diff." "P-value (H0: diff =0, H1: diff!=0)") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		refcat( correct_StandardDG_1_n  "\textbf{Standard DG}" correct_DGoutsideoption9_1_n "\vspace{0.1em} \\ \textbf{DG with exit option}" ///
		correct_DGtake1_1_n "\vspace{0.1em} \\ \textbf{DG take 1}" , nolabel) ///
		replace 

		
		local varlist2 correct_DGtake5_1_n correct_DGtake5_2_n correct_DGtake5_3_n correct_DGtake5_4_n correct_DGtake5_5_n correct_DGtake5_6_n correct_DGtake5_7_n correct_DGtake5_8_n correct_DGtake5_9_n correct_DGtake5_10_n correct_DGtake5_11_n correct_DGtake5_12_n correct_DGtake5_13_n correct_DGtake5_14_n correct_DGtake5_15_n correct_DGtake5_16_n correct_DGtake5_17_n correct_DGtake5_18_n correct_DGtake5_19_n correct_DGtake5_20_n correct_DGtake5_21_n correct_DGQuiz_1_n correct_DGQuiz_2_n correct_DGQuiz_3_n correct_DGQuiz_4_n correct_DGQuiz_5_n correct_DGQuiz_6_n correct_DGQuiz_7_n correct_DGQuiz_8_n correct_DGQuiz_9_n correct_DGQuiz_10_n correct_DGQuiz_11_n correct_DGProduction_1_n correct_DGProduction_2_n correct_DGProduction_3_n correct_DGProduction_4_n correct_DGProduction_5_n correct_DGProduction_6_n correct_DGProduction_7_n correct_DGProduction_8_n correct_DGProduction_9_n correct_DGProduction_10_n  correct_DGProduction_11_n 
			
		
		estpost ttest `varlist2', by(gender)
		esttab using "$mainpath/table_DG_gender2_personal.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p(fmt(4))") ///
		collabels("Obs." "Mean (men)" "Mean (women)" "Diff." "P-value (H0: diff =0, H1: diff!=0)") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		refcat( correct_DGtake5_1_n "\vspace{0.1em} \\ \textbf{DG take 5}" ///
		correct_DGQuiz_1_n "\vspace{0.1em} \\ \textbf{DG quiz}" correct_DGProduction_1_n "\vspace{0.1em} \\ \textbf{DG production}", nolabel) ///
		replace 

		
		
		*C) ORDER EFFECT
		
		*1) Hypotheses and Tests: Order effects -> compare (i) average rating by subjects who saw that game as the first game in the whole experiment, with (ii) average rating by all other subjects (i.e. all subjects who did not see that game as the first game in the whole experiment), under the same mode of appropriateness.
	
	gen FL_35_DO_first= substr(FL_35_DO, 1, 10) 
	gen FL_55_DO_first= substr(FL_55_DO, 1, 10) 
	gen FL_75_DO_first= substr(FL_75_DO, 1, 10) 
	gen FL_68_DO_first= substr(FL_68_DO, 1, 10) 
	
	gen DGwitouthistory_first = 1 if strpos(FL_35_DO_first, "DG(without") | strpos(FL_55_DO_first, "DG(without") | strpos(FL_75_DO_first, "DG(without") | strpos(FL_68_DO_first, "DG(without")
	replace DGwitouthistory_first = 0 if DGwitouthistory_first==.
	
	gen DG_standard_first = 1 if strpos(DGwithouthistory_DO, "Standard DG") & DGwitouthistory_first == 1
		replace  DG_standard_first=0 if DG_standard_first==.
		label var DG_standard_first "St. DG first"
	
	gen DG_take1_first = 1 if strpos(DGwithouthistory_DO, "DG take 1") & DGwitouthistory_first == 1
		replace  DG_take1_first=0 if DG_take1_first==.
		label var DG_take1_first "DG take 1 first"
	
	gen DG_take5_first = 1 if strpos(DGwithouthistory_DO, "DG take 5") & DGwitouthistory_first == 1
		replace  DG_take5_first=0 if  DG_take5_first ==. 
		label var DG_take5_first "DG take 5 first"
		
	gen DG_option9_first = 1 if strpos(DGwithouthistory_DO, "DG outside option $9") & DGwitouthistory_first == 1
		replace  DG_option9_first=0 if DG_option9_first==.
		label var DG_option9_first "DG exit opt. first"
	
	gen DGproquiz_first = 1 if strpos(FL_35_DO_first, "DGQuiz&Pro") 
	
	gen DG_production_first = 1 if strpos(DGQuizProduction_DO, "DG Production") & DGproquiz_first ==1
		replace  DG_production_first=0 if DG_production_first==.
		label var DG_production_first "DG prod. first"
	
	gen DG_quiz_first = 1 if strpos(DGQuizProduction_DO, "DG Quiz") & DGproquiz_first  == 1
		replace  DG_quiz_first=0 if DG_quiz_first==. 
		label var DG_quiz_first "DG quiz first"
	
	forvalues i=1/11 {
		local p=`i'-1
		label var StandardDG_`i'_n "St. DG (`p')"
	    label var DGProduction_`i'_n "Production DG (`p')"
		label var DGQuiz_`i'_n "Quiz DG (`p')"
	}
	
	forvalues i=1/12 {
		local p=`i'-1
		label var DGoutsideoption9_`i'_n "DG exit (`p')"
		
	}
	
	forvalues i=1/13 {
		local p=`i'-3
		label var DGtake1_`i'_n "DG take 1 (`p')"
		}
		
	
	
	forvalues i=1/21 {
		local p=`i'-11
		label var DGtake5_`i'_n "DG take 5 (`p')"
	}	

	local varlist1 StandardDG_1_n StandardDG_2_n StandardDG_3_n StandardDG_4_n StandardDG_5_n StandardDG_6_n StandardDG_7_n StandardDG_8_n StandardDG_9_n StandardDG_10_n StandardDG_11_n 
	foreach var in `varlist1'{
			ttest `var' , by(DG_standard_first)
	}
	estpost ttest `varlist1', by(DG_standard_first)
	esttab using "$mainpath/table_DG_standard_fisrt_personal.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p(fmt(4))") ///
		collabels("Obs." "Mean (others)" "Mean (seen fisrt)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		replace
	
	local varlist2 DGoutsideoption9_1_n DGoutsideoption9_2_n DGoutsideoption9_3_n DGoutsideoption9_4_n DGoutsideoption9_5_n DGoutsideoption9_6_n DGoutsideoption9_7_n DGoutsideoption9_8_n DGoutsideoption9_9_n DGoutsideoption9_10_n DGoutsideoption9_11_n DGoutsideoption9_12_n 
	foreach var in `varlist2' {
		ttest `var' , by(DG_option9_first)
	}
	estpost ttest `varlist2', by(DG_option9_first)
	esttab using "$mainpath/table_DG_option9_first_personal.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p(fmt(4))") ///
		collabels("Obs." "Mean (others)" "Mean (seen fisrt)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		replace
		
	local varlist3 DGtake1_1_n DGtake1_2_n DGtake1_3_n DGtake1_4_n DGtake1_5_n DGtake1_6_n DGtake1_7_n DGtake1_8_n DGtake1_9_n DGtake1_10_n DGtake1_11_n DGtake1_12_n DGtake1_13_n 
	foreach var in `varlist3' {
		ttest `var' , by(DG_take1_first)
	}
	estpost ttest `varlist3', by(DG_take1_first)
	esttab using "$mainpath/table_DG_take1_first_personal.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p_l(fmt(4))") ///
		collabels("Obs." "Mean (others)" "Mean (seen fisrt)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		replace
	
	local varlist4 DGtake5_1_n DGtake5_2_n DGtake5_3_n DGtake5_4_n DGtake5_5_n DGtake5_6_n DGtake5_7_n DGtake5_8_n DGtake5_9_n DGtake5_10_n DGtake5_11_n DGtake5_12_n DGtake5_13_n DGtake5_14_n DGtake5_15_n DGtake5_16_n DGtake5_17_n DGtake5_18_n DGtake5_19_n DGtake5_20_n DGtake5_21_n 
	foreach var in `varlist4'{
		ttest `var' , by(DG_take5_first)
	}
	estpost ttest `varlist4', by(DG_take5_first)
	esttab using "$mainpath/table_DG_take5_first_personal.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p_l(fmt(4))") ///
		collabels("Obs." "Mean (others)" "Mean (seen fisrt)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		replace


	local varlist5 DGProduction_1_n DGProduction_2_n DGProduction_4_n DGProduction_5_n DGProduction_6_n DGProduction_7_n DGProduction_8_n DGProduction_9_n DGProduction_10_n DGProduction_11_n 
	foreach var in `varlist5' {
		ttest `var' , by(DG_production_first )
	}
	estpost ttest `varlist5', by(DG_production_first)
	esttab using "$mainpath/table_DG_production_first_personal.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p_l(fmt(4))") ///
		collabels("Obs." "Mean (others)" "Mean (seen fisrt)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		replace
	

	
	local varlist6  DGQuiz_1_n DGQuiz_2_n DGQuiz_3_n DGQuiz_4_n DGQuiz_5_n DGQuiz_6_n DGQuiz_8_n DGQuiz_9_n DGQuiz_10_n DGQuiz_11_n
	foreach var in `varlist6' {
		ttest `var' , by(DG_quiz_first)
	}
	
	estpost ttest `varlist6', by(DG_quiz_first)
	esttab using "$mainpath/table_DG_quiz_first_personal.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p_l(fmt(4))") ///
		collabels("Obs." "Mean (others)" "Mean (seen fisrt)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		replace

	* test at the level of games
	
	// DG stabdard
	local varlist1 StandardDG_1_n StandardDG_2_n StandardDG_3_n StandardDG_4_n StandardDG_5_n StandardDG_6_n StandardDG_7_n StandardDG_8_n StandardDG_9_n StandardDG_10_n StandardDG_11_n 
	eststo: reg DG_standard_first `varlist1'
	esttab using "$mainpath/table_DG_standard_OE_personal.tex", se scalars(F p)   wide label replace
	eststo clear 
	
	// DG with exit option
	local varlist2 DGoutsideoption9_1_n DGoutsideoption9_2_n DGoutsideoption9_3_n DGoutsideoption9_4_n DGoutsideoption9_5_n DGoutsideoption9_6_n DGoutsideoption9_7_n DGoutsideoption9_8_n DGoutsideoption9_9_n DGoutsideoption9_10_n DGoutsideoption9_11_n DGoutsideoption9_12_n 
	eststo: reg DG_option9_first `varlist2'
	esttab using "$mainpath/table_DG_option9_OE_personal.tex", se scalars(F p) wide label replace
	eststo clear 

	// DG with take 1 optioin	
	local varlist3 DGtake1_1_n DGtake1_2_n DGtake1_3_n DGtake1_4_n DGtake1_5_n DGtake1_6_n DGtake1_7_n DGtake1_8_n DGtake1_9_n DGtake1_10_n DGtake1_11_n DGtake1_12_n DGtake1_13_n 
	eststo: reg DG_take1_first `varlist3'
	eststo: esttab using "$mainpath/table_DG_take1_OE_personal.tex", se scalars(F p) wide label replace
	eststo clear 

	// DG with take 5 option
	local varlist4 DGtake5_1_n DGtake5_2_n DGtake5_3_n DGtake5_4_n DGtake5_5_n DGtake5_6_n DGtake5_7_n DGtake5_8_n DGtake5_9_n DGtake5_10_n DGtake5_11_n DGtake5_12_n DGtake5_13_n DGtake5_14_n DGtake5_15_n DGtake5_16_n DGtake5_17_n DGtake5_18_n DGtake5_19_n DGtake5_20_n DGtake5_21_n 
	eststo: reg DG_take5_first `varlist4'
	esttab using "$mainpath/table_DG_take5_OE_personal.tex", se scalars(F p) wide label replace 
	eststo clear 

	// DG with production
	local varlist5 DGProduction_1_n DGProduction_2_n DGProduction_4_n DGProduction_5_n DGProduction_6_n DGProduction_7_n DGProduction_8_n DGProduction_9_n DGProduction_10_n DGProduction_11_n 
	eststo: reg DG_production_first `varlist5'
	esttab using "$mainpath/table_DG_production_OE_personal.tex", se scalars(F p) wide label replace
	eststo clear 


	// DG with quiz
	local varlist6  DGQuiz_1_n DGQuiz_2_n DGQuiz_3_n DGQuiz_4_n DGQuiz_5_n DGQuiz_6_n DGQuiz_8_n DGQuiz_9_n DGQuiz_10_n DGQuiz_11_n
	reg DG_quiz_first `varlist6' 
	 esttab using "$mainpath/table_DG_quiz_OE_personal.tex", se scalars(F p) wide label replace
	 eststo clear 
	
	
*END
}




clear all 

global mainpath "/Users/petterhallqvist/Desktop/tore_ellingsen/crowding_multiple_games_combined"
cd "$mainpath"


*------------------------------------------------------------------------------*
capt prog drop prtesttab
program prtesttab, rclass
args `varlist'
prtest `1' == 0.5
return list

matrix B = (r(N), r(P), r(se), r(p_u))
matrix colnames B = N P se p_u

local label: di "`: var label `1' '" 
mat rownames B = "`label'"

matmap B A, map(round(@, 0.0001))

end	

global always1 "booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("N(fmt(%9.1fc)) P(fmt(%9.1fc)) se(fmt(%9.1fc)) p_u(fmt(%9.1fc)) " ) fragment nolines nogaps nomtitles nocons label "

capt prog drop ttesttab
program ttesttab, rclass
args `varlist'
ttest `1' == `2'
return list

matrix B = (r(mu_1), r(mu_2), r(mu_1) - r(mu_2), r(p_l))
matrix colnames B = mu_1 mu_2 diff p_l

local label: di "`: var label  `1' ' - `: var label `2'' "
mat rownames B = "`label'"
matmap B A, map(round(@, 0.0001))
mat list B

end	
 
global always2 "booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("mu_1(fmt(%9.1fc)) mu_2(fmt(%9.1fc)) diff(fmt(%9.1fc)) p_l(fmt(%9.1fc))" ) fragment nolines nogaps nomtitles nocons label "

						*-------------------*
						* HYPOTESIS TESTING *
						*-------------------*
						
					

forvalue i =5 (2) 7 {
*use "$in/`i'scale_BEARB_merged_cleaned.dta", clear 
use "$mainpath/5scale_BEARB_merged_cleaned.dta", clear 

//---------- HYPOTESIS TESTING DISREGARDING THE ORDER 						
	
	* 1) LOST WALLET SITUATION
		
		* SOCIAL APPROPIATENESS
		label var Walletnomoney_1_n    "No money"
		label var Walletsmallmoney_1_n "Small money"
		label var Walletbigmoney_1_n   "Big money"
					
		gen lw_inappr = (Walletnomoney_1_n<0 | Walletsmallmoney_1_n<0 | Walletbigmoney_1_n<0)
		replace lw_inappr =. if Condition =="2" // only partecipant to repond to the social appropriate question
		label var lw_inappr "Social appropriateness"
		
		* Inappropriateness of not returning
		prtest lw_inappr==.5
		
		local varlist lw_inappr
		prtesttab `varlist'
		esttab matrix(A) using "$mainpath/table_1l_`i'scale.tex", replace $always1 
		eststo clear 

		// we can reject the null, most people consider not returnin inappropriate
		
		* Comparing the inappropiateness of not returning when wallet contains small money or no money (alternative 2) 
		ttest Walletsmallmoney_1_n == Walletnomoney_1_n // cannot reject the null.
		
		local varlist Walletsmallmoney_1_n  Walletnomoney_1_n	
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2la_`i'scale.tex", replace $always2 ///
		prehead( "\textbf{SA:}" )
		eststo clear 		
		
		* Inappropiateness of not returning increasing in monetary content  (alternative 2)  
		ttest Walletbigmoney_1_n == Walletsmallmoney_1_n
			
		local varlist Walletbigmoney_1_n Walletsmallmoney_1_n	
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2lb_`i'scale.tex", replace $always2 ///
		prehead( "\textbf{SA:}" )
		eststo clear

		* PERSONAL INAPPROPIATENESS 
		label var Q49_1_n  "No money"
		label var Q50_1_n  "Small Money"
		label var Q51_1_n  "Big money"
		
		gen lw_inappr_p = (Q49_1_n <0| Q50_1_n<0 | Q51_1_n<0)
		replace lw_inappr_p =. if Condition == "1"
		label var lw_inappr_p "Personal appropriateness"
		eststo clear
		
		* Inappropriateness of not returning
		prtest lw_inappr_p ==.5 // we can reject the null, most people consider not returnin inappropriate
		local varlist lw_inappr_p 
		prtesttab `varlist'
		esttab matrix(A) using "$mainpath/table_1l_`i'scale.tex", append $always1 
		eststo clear
		
		* Comparing the inappropiateness of not returning when wallet contains small money or no money  (alternative 2) 
		ttest Q50_1_n  == Q49_1_n // cannot reject the null. 
		
		local varlist Q50_1_n Q49_1_n
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2la_`i'scale.tex", append $always1 ///
		prehead( "\textbf{PA:}" )
		eststo clear
	
		* Inappropiateness of not returning increasing in monetary content  (alternative 2) 
		ttest Q51_1_n == Q50_1_n // cannot reject the null. 
	
		local varlist Q51_1_n Q50_1_n	
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2lb_`i'scale.tex", append $always1 ///
		prehead( "\textbf{PA:}" )
	    eststo clear
		
	*  2) DAY-CARE CENTER SITUATION
	
		* SOCIAL APPROPIATENESS
		label var Daycarenofine_2_n     "No fine (15)"
		label var Daycarenofine_3_n     "No fine (30)"
		label var Daycaresmallfine_2_n  "Small fine (15)"
		label var Daycaresmallfine_3_n  "Small fine (30)"
		label var Daycarebigfine_2_n    "Big fine (15)"
		label var Daycarebigfine_3_n    "Big fine (30)"
		
		gen dc_inapp = (Daycarenofine_2_n <0 | Daycaresmallfine_2_n<0 | Daycarebigfine_2_n<0 | Daycaresmallfine_3_n<0 | Daycarebigfine_3_n<0 | Daycarenofine_3_n <0)
		label var dc_inapp "Social appropriateness"
		replace dc_inapp =. if Condition == "2"

		* Inappropriateness of picking up late
		prtest dc_inapp == .5 // we can reject the null, most people consider inappropriate to arrive late 
		local varlist dc_inapp
		prtesttab `varlist'
		esttab matrix(A) using "$mainpath/table_1d_`i'scale.tex", replace $always1
		eststo clear
		
		* Comparing the inappropiateness of arriving late under samll fine and no fine
		ttest  Daycarenofine_2_n == Daycaresmallfine_2_n  // 15 mins late 
		local varlist Daycarenofine_2_n Daycaresmallfine_2_n	
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2da_`i'scale.tex", replace $always2 ///
		prehead( "\textbf{SA:}" )
		eststo clear
	
		ttest Daycarenofine_3_n == Daycaresmallfine_3_n // 30 mins late 
		local varlist Daycarenofine_3_n Daycaresmallfine_3_n	
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2da_`i'scale.tex", append $always2 ///
		prehead( "\textbf{SA:}" )
		eststo clear
		
		* Comparing the inappropiateness of arriving late under big fine and no fine
		ttest Daycarenofine_2_n == Daycarebigfine_2_n  // 15 mins late 
		local varlist Daycarenofine_2_n Daycarebigfine_2_n	
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2da_`i'scale.tex", append $always2 ///
		prehead( "\textbf{SA:}" )
		eststo clear
	
		ttest Daycarenofine_3_n == Daycarebigfine_3_n // 30 mins late 
		local varlist Daycarenofine_3_n Daycarebigfine_3_n	
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2da_`i'scale.tex", append $always2 ///
		prehead( "\textbf{SA:}" )
		eststo clear
		
		* Comparing inappropriateness under small and lare fine
		ttest Daycaresmallfine_2_n  == Daycarebigfine_2_n  // 15 mins late 
		local varlist Daycaresmallfine_2_n Daycarebigfine_2_n	
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2db_`i'scale.tex", replace $always2 ///
		prehead( "\textbf{SA:}" )
		eststo clear
		
		ttest Daycaresmallfine_3_n  == Daycarebigfine_3_n // 30mins late
		local varlist Daycaresmallfine_3_n Daycarebigfine_3_n	
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2db_`i'scale.tex", append $always2 ///
		prehead( "\textbf{SA:}" )
		eststo clear
		
		* PERSONAL INAPPROPIATENESS 
		label var Q52_2_n  "No fine (15)"
		label var Q52_3_n  "No fine (30)"
		label var Q53_2_n  "Small fine (15)"
		label var Q53_3_n  "Small fine (30)"
		label var Q54_2_n  "Big fine (15)"
		label var Q54_3_n  "Big fine (30)"

		gen dc_inappr_p = (Q52_2_n <0| Q52_3_n<0 | Q53_2_n <0| Q53_3_n<0 | Q54_2_n <0| Q54_3_n<0)
		label var dc_inappr_p "Personal appropriateness"
		replace dc_inappr_p =. if Condition == "1"
		
		* Inappropriateness of picking up late regardless of the fine
		prtest dc_inappr_p ==.5
		
		local varlist dc_inappr_p 
		prtesttab `varlist'
		esttab matrix(A) using "$mainpath/table_1d_`i'scale.tex", append $always1 
		eststo clear
		
		* Comparing the inappropiateness of picking up late under small fine and no fine  
		ttest Q52_2_n == Q53_2_n // 15 mins late 
		local varlist Q52_2_n Q53_2_n	
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2da_`i'scale.tex", append $always2 ///
		prehead( "\textbf{PA:}" )
		eststo clear
		
		ttest Q52_3_n == Q53_3_n // 30 mins late 
		local varlist Q52_3_n Q53_3_n
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2da_`i'scale.tex", append $always2 ///
		prehead( "\textbf{PA:}" )	
		eststo clear
		
		* Comparing the inappropiateness of arriving late under big fine and no fine
		ttest Q52_2_n == Q54_2_n  // 15 mins late 
		local varlist Q52_2_n Q54_2_n	
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2da_`i'scale.tex", append $always2 ///
		prehead( "\textbf{SA:}" )
		eststo clear
	
		ttest Q52_3_n == Q54_3_n  // 15 mins late 
		local varlist Q52_3_n Q54_3_n	
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2da_`i'scale.tex", append $always2 ///
		prehead( "\textbf{SA:}" )
		eststo clear
		
		* Comparing inappropiateness under small and large fine 
		ttest Q53_2_n  == Q54_2_n // 15 mins late 
		local varlist Q53_2_n Q54_2_n
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2db_`i'scale.tex", append $always2 ///
		prehead( "\textbf{PA:}" )
		eststo clear
		
		ttest Q53_3_n == Q54_3_n // 30 mins late 
		local varlist Q53_3_n Q54_3_n
		ttesttab `varlist'
		esttab matrix(A) using "$mainpath/table_2db_`i'scale.tex", append $always2 ///
		prehead( "\textbf{PA:}" )	
		eststo clear
		
		*TABLE 2 - day care situation 
		
		
	* 3) GENDER DIFFERENCES 
		gen gender  = (Sex_n==1)
			
		* SOCIAL APPROPIATENESS
		local varlist Walletnomoney_1_n Walletsmallmoney_1_n Walletbigmoney_1_n Daycarenofine_2_n Daycarenofine_3_n Daycaresmallfine_2_n Daycaresmallfine_3_n Daycarebigfine_2_n Daycarebigfine_3_n
		foreach var in `varlist' {
				
				egen mode_`var' = mode(`var')
				gen correct_`var' =  (`var' == mode_`var')
				replace correct_`var' = . if Condition =="2"
				order mode_`var' correct_`var', after (`var')
				
				}
				
		label var correct_Walletnomoney_1_n     "Wallet with no money"
		label var correct_Walletsmallmoney_1_n  "Wallet with small money"
		label var correct_Walletbigmoney_1_n    "Wallet with big money"
		label var correct_Daycarenofine_2_n     "15 minutes delay with no fine"
		label var correct_Daycarenofine_3_n     "30 minutes delay with no fine"
		label var correct_Daycaresmallfine_2_n  "15 minutes delay with small fine"
		label var correct_Daycaresmallfine_3_n  "30 minutes delay with small fine"
		label var correct_Daycarebigfine_2_n    "15 minutes delay with big fine"
		label var correct_Daycarebigfine_3_n    "30 minutes delay with big fine"
		
		local varlist correct_Walletnomoney_1_n correct_Walletsmallmoney_1_n correct_Walletbigmoney_1_n correct_Daycarenofine_2_n ///
					  correct_Daycarenofine_3_n correct_Daycaresmallfine_2_n correct_Daycaresmallfine_3_n correct_Daycarebigfine_2_n  ///
					  correct_Daycarebigfine_3_n
		
		foreach var in `varlist' {
				ttest `var', by(gender)
				}
		
		* TABLE
		estpost ttest correct_Walletnomoney_1_n correct_Walletsmallmoney_1_n correct_Walletbigmoney_1_n correct_Daycarenofine_2_n ///
					  correct_Daycarenofine_3_n correct_Daycaresmallfine_2_n correct_Daycaresmallfine_3_n correct_Daycarebigfine_2_n  ///
					  correct_Daycarebigfine_3_n, by(gender)
		esttab using "$mainpath/table_3_`i'scale.tex",  noobs nonumber  label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4))  p_l(fmt(4))") ///
		collabels("Obs." "Mean (men)" "Mean (women)" "Diff." "P-value") ///
		addnotes("* p<0.05, ** p<0.01, *** p<0.001" ) ///
		refcat( correct_Walletnomoney_1_n  "\textbf{Lost Wallet Scenario (not returning)}" correct_Daycarenofine_2_n "\vspace{0.1em} \\ \textbf{Day Care Scenario (arriving late)}", nolabel) ///
		replace
		
		* PERSONAL INAPPROPIATENESS 
		local varlist Q49_1_n Q50_1_n Q51_1_n Q52_2_n Q52_3_n Q53_2_n Q53_3_n Q54_2_n Q54_3_n
		foreach var in `varlist' {
		
				egen mode_`var' = mode(`var')
				gen correct_`var' =  (`var' == mode_`var')
				replace correct_`var' = . if Condition =="1"
				order mode_`var' correct_`var', after (`var')
				}
				
		label var correct_Q49_1_n  "No money"
		label var correct_Q50_1_n  "Small money"
		label var correct_Q51_1_n  "Big money"
		label var correct_Q52_2_n  "15 min no fine"
		label var correct_Q52_3_n  "30 min no fine"
		label var correct_Q53_2_n  "15 min small fine"
		label var correct_Q53_3_n  "30 min small fine"
		label var correct_Q54_2_n  "15 min big fine"
		label var correct_Q54_3_n  "30 min big fine"

		local varlist correct_Q49_1_n correct_Q50_1_n correct_Q51_1_n correct_Q52_2_n correct_Q52_3_n correct_Q53_2_n correct_Q53_3_n correct_Q54_2_n correct_Q54_3_n
		foreach var in `varlist' {
				ttest `var', by(gender)
				}
		
		
		* TABLE
		estpost ttest correct_Q49_1_n correct_Q50_1_n correct_Q51_1_n correct_Q52_2_n correct_Q52_3_n correct_Q53_2_n correct_Q53_3_n correct_Q54_2_n correct_Q54_3_n, by(gender)
		esttab using "$mainpath/table_4_`i'scale.tex",  noobs nonumber label ///
		cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p_l(fmt(4)) ") ///
		collabels("Obs." "Mean (men)" "Mean (women)" "Diff." "P-value") ///
		addnotes( "* p<0.05, ** p<0.01, *** p<0.001" ) ///
		refcat(correct_Q49_1_n  "\textbf{Lost Wallet Scenario (not returning)}" correct_Q52_2_n "\vspace{0.1em} \\ \textbf{Day Care Scenario (arriving late)}", nolabel) ///
		replace
		
//---------- HYPOTESIS TESTING WITH ORDER EFFECTS
	* 1) Test at level of questions/actions
		
		* SOCIAL APPROPIATENESS
		*LW first
		gen FL_30_DO_bis = substr(FL_30_DO,14,5)
		order FL_30_DO_bis, after(FL_30_DO)
			
		gen lw_no_first = (Condition =="1" & FL_5_DO=="FL_30|FL_31" & strpos(FL_30_DO_bis, "No"))
		replace lw_no_first  =. if Condition =="2"
		
		gen lw_small_first = (Condition =="1" & FL_5_DO=="FL_30|FL_31" & strpos(FL_30_DO_bis, "Small"))	
		replace lw_small_first =. if Condition =="2"
		
		gen lw_big_first = (Condition =="1" & FL_5_DO=="FL_30|FL_31" & strpos(FL_30_DO_bis, "Big"))	
		replace lw_big_first =. if Condition =="2"
				
		label variable lw_no_first           "No money version first"
		label variable lw_small_first        "Small money version first"
		label variable lw_big_first          "Big money version first"
		
		eststo: estpost ttest Walletnomoney_1_n, by(lw_no_first)
		eststo: estpost ttest Walletsmallmoney_1_n, by(lw_small_first)
		eststo: estpost ttest Walletbigmoney_1_n, by(lw_big_first)
		
			
		*DC first 
		gen FL_31_DO_bis = substr(FL_31_DO,18,5)
		order FL_31_DO_bis, after(FL_31_DO)
		
		 
		gen dc_no_first = (Condition =="1" & FL_5_DO=="FL_31|FL_30" & strpos(FL_31_DO_bis, "No"))
		replace dc_no_first  =. if Condition =="2"
		gen dc_small_first = (Condition =="1" & FL_5_DO=="FL_31|FL_30" & strpos(FL_31_DO_bis, "Small"))	
		replace dc_small_first  =. if Condition =="2"
		gen dc_big_first = (Condition =="1" & FL_5_DO=="FL_31|FL_30" & strpos(FL_31_DO_bis, "Big"))
		replace dc_big_first  =. if Condition =="2"
		
		label variable dc_no_first     "Delay of 15 min with no fine first"
		label variable dc_small_first  "Delay of 15 min with small fine first"
		label variable dc_big_first    "Delay of 15 min with big fine first"
		

		eststo: estpost ttest Daycarenofine_2_n, by(dc_no_first)
		eststo: estpost ttest Daycaresmallfine_2_n, by(dc_small_first)
		eststo: estpost ttest Daycarebigfine_2_n, by(dc_big_first)			
		
		// 30 minutes late scenario 
		gen dc_no_first_30 = (Condition =="1" & FL_5_DO=="FL_31|FL_30" & strpos(FL_31_DO_bis, "No"))
		replace dc_no_first_30 =. if Condition =="2"
		
		gen dc_small_first_30 = (Condition =="1" & FL_5_DO=="FL_31|FL_30" & strpos(FL_31_DO_bis, "Small"))
		replace dc_small_first_30  =. if Condition =="2"

		gen dc_big_first_30 = (Condition =="1" & FL_5_DO=="FL_31|FL_30" & strpos(FL_31_DO_bis, "Big"))
		replace dc_big_first_30 =. if Condition =="2"
			
		label variable dc_no_first_30     "Delay of 30 min with no fine first"
		label variable dc_small_first_30  "Delay of 30 min with small fine first"
		label variable dc_big_first_30    "Delay of 30 min with big fine first"
		
		eststo: estpost ttest Daycarenofine_3_n, by(dc_no_first_30)
		eststo: estpost ttest Daycaresmallfine_3_n, by(dc_small_first_30)
		eststo: estpost ttest Daycarebigfine_3_n, by(dc_big_first_30)	
			
		
		* TABLE 5 - social appropriateness 
		esttab est1 using "$mainpath/table_5a_`i'scale.tex", replace booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est2 using "$mainpath/table_5a_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est3 using "$mainpath/table_5a_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est4 using "$mainpath/table_5b_`i'scale.tex", replace booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est5 using "$mainpath/table_5b_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est6 using "$mainpath/table_5b_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4)) ") fragment nolines nogaps nomtitles nocons label 
		
		esttab est7 using "$mainpath/table_5b_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est8 using "$mainpath/table_5b_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est9 using "$mainpath/table_5b_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 

		eststo clear 
		
		*PERSONAL APPROPIATENESS 
		*LW first 
		
		gen FL_32_DO_bis = substr(FL_32_DO,16,5)
		order FL_32_DO_bis, after(FL_32_DO)
		
		gen lw_no_first_p = (Condition =="2" & FL_9_DO=="FL_32|FL_33" & strpos(FL_32_DO_bis, "No"))
		replace lw_no_first_p=.  if Condition =="1"
		
		
		gen lw_small_first_p = (Condition =="2" & FL_9_DO=="FL_32|FL_33" & strpos(FL_32_DO_bis, "Small"))
		replace lw_small_first_p=.  if Condition =="1"
		
		gen lw_big_first_p = (Condition =="2" & FL_9_DO=="FL_32|FL_33" & strpos(FL_32_DO_bis, "Big"))
		replace lw_big_first_p=.  if Condition =="1"
		
		label variable lw_no_first           "No money version first"
		label variable lw_small_first        "Small money version first"
		label variable lw_big_first          "Big money version first"
		tab Q49_1_n
		eststo: estpost ttest Q49_1_n, by(lw_no_first_p)
		eststo: estpost ttest Q50_1_n, by(lw_small_first_p)
		eststo: estpost ttest Q51_1_n, by(lw_big_first_p)
		
		* DC first 
		gen FL_33_DO_bis = substr(FL_33_DO,20,5)
		order FL_33_DO_bis, after(FL_33_DO)
		
		// 15 minutes late scenario 
		gen dc_no_first_p = (Condition =="2" & FL_9_DO=="FL_33|FL_32" & strpos(FL_33_DO_bis, "No"))
		replace dc_no_first_p =.  if Condition =="1"
		
		gen dc_small_first_p = (Condition =="2" & FL_9_DO=="FL_33|FL_32" & strpos(FL_33_DO_bis, "Small"))
		replace dc_small_first_p=.  if Condition =="1"			
		
		gen dc_big_first_p = (Condition =="2" & FL_9_DO=="FL_33|FL_32" & strpos(FL_33_DO_bis, "Big"))
		replace dc_big_first_p=.  if Condition =="1"
		
		label variable dc_no_first_p     "Delay of 15 min with no fine first"
		label variable dc_small_first_p  "Delay of 15 min with small fine first"
		label variable dc_big_first_p    "Delay of 15 min with big fine first"
			
		eststo: estpost ttest Q52_2_n , by(dc_no_first_p)
		eststo: estpost ttest Q53_2_n , by(dc_small_first_p)
		eststo: estpost ttest Q54_2_n, by(dc_big_first_p)

		//30 minutes late scenario 
		gen dc_no_first_30_p = (Condition =="2" & FL_9_DO=="FL_33|FL_32" & strpos(FL_33_DO_bis, "No"))
		replace dc_no_first_30_p =.  if Condition =="1"
		
		gen dc_small_first_30_p = (Condition =="2" & FL_9_DO=="FL_33|FL_32" & strpos(FL_33_DO_bis, "Big"))
		replace dc_small_first_30_p =.  if Condition =="1"
		
		gen dc_big_first_30_p = (Condition =="2" & FL_9_DO=="FL_33|FL_32" & strpos(FL_33_DO_bis, "Big"))
		replace dc_big_first_30_p =.  if Condition =="1"
			
		label variable dc_no_first_30_p     "Delay of 30 min with no fine first"
		label variable dc_small_first_30_p  "Delay of 30 min with small fine first"
		label variable dc_big_first_30_p    "Delay of 30 min with big fine first"

		eststo: estpost ttest Q52_3_n, by(dc_no_first_30_p)
		eststo: estpost ttest Q53_3_n, by(dc_small_first_30_p)
		eststo: estpost ttest Q54_3_n, by(dc_big_first_30_p)
			
					
		* TABLE 6 - personal appropriateness 
		esttab est1 using "$mainpath/table_6a_`i'scale.tex", replace booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0))  mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est2 using "$mainpath/table_6a_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells(" count(fmt(0))  mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est3 using "$mainpath/table_6a_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4)) ") fragment nolines nogaps nomtitles nocons label 
		
		esttab est4 using "$mainpath/table_6b_`i'scale.tex", replace booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0))  mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est5 using "$mainpath/table_6b_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est6 using "$mainpath/table_6b_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est7 using "$mainpath/table_6b_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))")  fragment nolines nogaps nomtitles nocons label 
		
		esttab est8 using "$mainpath/table_6b_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0)) mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		esttab est9 using "$mainpath/table_6b_`i'scale.tex", append booktabs nomtitle nonumbers noobs nodep star( * 0.10 ** 0.05 *** 0.01) collabels(none) cells("count(fmt(0))  mu_1(fmt(4)) mu_2(fmt(4)) b(star fmt(4)) p(fmt(4))") fragment nolines nogaps nomtitles nocons label 
		
		eststo clear 
			
	* 2) Test at level of scenarios: use each action in the scenario are regressors to predict if the subject saw the scenario.
	
	 * LW or DC - social apporpriateness
	 tab FL_5_DO
	 gen lw_first = 1 if FL_5_DO=="FL_30|FL_31"
	 replace lw_first = 0 if FL_5_DO=="FL_31|FL_30"
	 label var lw_first "Lost wallet situation first"
	 
	 label var Walletnomoney_2_n "Returning wallet with no money"
	 label var Walletnomoney_1_n "Not returning wallet with no money"
	 label var Walletsmallmoney_2_n "Returning wallet with small money"
	 label var Walletsmallmoney_1_n "Not Returning wallet with small money"	 
	 label var Walletbigmoney_2_n "Returning wallet with big money"
	 label var Walletbigmoney_2_n "Not Returning wallet with big money"
	 label var Daycarenofine_1_n "Arriving in time with no fine"
	 label var Daycarenofine_2_n "15 mins of delay with no fine"
	 label var Daycarenofine_3_n "30 mins of delay with no fine"
	 label var Daycaresmallfine_1_n "Arriving in time with small fine"
	 label var Daycaresmallfine_2_n "15 mins delay with small fine"
	 label var Daycaresmallfine_3_n "30 mins delay with small fine"
	 label var Daycarebigfine_1_n "Arriving in time with big fine"
	 label var Daycarebigfine_2_n "15 mins of delay with big fine"
	 label var Daycarebigfine_3_n "30 mins of delay with big fine"
	 
	 local regressors Walletnomoney_1_n Walletsmallmoney_1_n Walletbigmoney_1_n  Daycarenofine_2_n Daycarenofine_3_n Daycaresmallfine_2_n Daycaresmallfine_3_n Daycarebigfine_2_n Daycarebigfine_3_n
	 
	 eststo clear
	 eststo: reg lw_first `regressors'
	 esttab using "$mainpath/table_7_`i'scale.tex", se scalars(F) label replace
	 
	 * LW or DC - personal apporpriateness
	 tab FL_9_DO
	 gen lw_first_pa = 1 if FL_9_DO=="FL_32|FL_33"
	 replace lw_first_pa = 0 if FL_9_DO=="FL_33|FL_32"
	 label var lw_first_pa  "Lost wallet situation first"
	 
	 label var Q49_2_n "Returning wallet with no money"
	 label var Q49_1_n "Not returning wallet with no money"	 
	 label var Q50_2_n "Returning wallet with small money"
	 label var Q50_1_n "Not returning wallet with small money"
	 label var Q51_2_n "Returning wallet with big money"
	 label var Q51_1_n "Not returning wallet with big money"
	 
	 label var Q52_1_n "Arriving in time under no fine"
	 label var Q52_2_n "Not arriving in time (15) under no fine"
	 label var Q52_3_n "Not arriving in time (30) under no fine"
	 label var Q53_1_n "Arriving in time under samll fine"
	 label var Q53_2_n "Not arriving in time (15) under samll fine"
	 label var Q53_3_n "Not arriving in time (30) with samll fine"
	 label var Q54_1_n "Arriving in time with big fine"
	 label var Q54_2_n "Not arriving in time (15) under big fine"
	 label var Q54_3_n "Not arriving in time (30) with big fine"
	 
	 local regressors Q49_1_n Q50_1_n Q51_1_n Q52_2_n Q52_3_n Q53_2_n Q53_3_n Q54_2_n Q54_3_n
	 
	 eststo clear
	 eststo: reg lw_first_pa `regressors'
	 esttab using "$mainpath/table_8_`i'scale.tex", se scalars(F) label replace
	 eststo clear 
	
***END
}
clear all 
global mainpath "/Users/petterhallqvist/Desktop/tore_ellingsen/crowding_multiple_games_combined"
cd "$mainpath"



/****************************************************************************
 * 2. Figures Section
 ****************************************************************************/

use "$mainpath/MultiplesGamesElicitation_Social_cleaned.dta", clear 



               ** SOCIAL APPROPRIATENESS **
				   
* DG standard and exit option 
preserve

	local varlist StandardDG_1_n StandardDG_2_n StandardDG_3_n StandardDG_4_n StandardDG_5_n StandardDG_6_n StandardDG_7_n StandardDG_8_n StandardDG_9_n StandardDG_10_n StandardDG_11_n ///
	              DGoutsideoption9_1_n DGoutsideoption9_2_n DGoutsideoption9_3_n DGoutsideoption9_4_n DGoutsideoption9_5_n DGoutsideoption9_6_n DGoutsideoption9_7_n DGoutsideoption9_8_n DGoutsideoption9_9_n DGoutsideoption9_10_n DGoutsideoption9_11_n DGoutsideoption9_12_n
	
	
	
	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if `var' !=.
		gen `var'_2 = (`var'==-0.5) if `var' !=.
		gen `var'_3 = (`var'==0) if `var' !=.
		gen `var'_4 = (`var'==0.5) if `var' !=.
		gen `var'_5 = (`var'==1)  if `var' !=.
		
	}
	
	gen obs_stDG = _n if StandardDG_1_n !=.
	gen obs_o9DG = _n if DGoutsideoption9_1_n !=.

	reshape long  StandardDG_1_n_@ StandardDG_2_n_@ StandardDG_3_n_@ StandardDG_4_n_@ StandardDG_5_n_@ StandardDG_6_n_@ StandardDG_7_n_@ StandardDG_8_n_@ StandardDG_9_n_@ StandardDG_10_n_@ StandardDG_11_n_@ DGoutsideoption9_1_n_@ DGoutsideoption9_2_n_@ DGoutsideoption9_3_n_@ DGoutsideoption9_4_n_@ DGoutsideoption9_5_n_@ DGoutsideoption9_6_n_@ DGoutsideoption9_7_n_@ DGoutsideoption9_8_n_@ DGoutsideoption9_9_n_@ DGoutsideoption9_10_n_@ DGoutsideoption9_11_n_@ DGoutsideoption9_12_n_@, i(participant_id) j(situation) string 
	
	collapse (count)  obs_stDG obs_o9DG (sum) StandardDG_1_n_ StandardDG_2_n_ StandardDG_3_n_ StandardDG_4_n_ StandardDG_5_n_ StandardDG_6_n_ StandardDG_7_n_ StandardDG_8_n_ StandardDG_9_n_ StandardDG_10_n_ StandardDG_11_n_ DGoutsideoption9_1_n_ DGoutsideoption9_2_n_ DGoutsideoption9_3_n_ DGoutsideoption9_4_n_ DGoutsideoption9_5_n_ DGoutsideoption9_6_n_ DGoutsideoption9_7_n_ DGoutsideoption9_8_n_ DGoutsideoption9_9_n_ DGoutsideoption9_10_n_ DGoutsideoption9_11_n_ DGoutsideoption9_12_n_, by(situation)
	
	destring situation, replace 
	replace situation = -1   if situation ==1 
	replace situation = -0.5 if situation ==2
	replace situation = 0    if situation ==3 
	replace situation = -0.5 if situation ==4
	replace situation = 1    if situation ==5	
		
	local varlist StandardDG_1_n_ StandardDG_2_n_ StandardDG_3_n_ StandardDG_4_n_ StandardDG_5_n_ StandardDG_6_n_ StandardDG_7_n_ StandardDG_8_n_ StandardDG_9_n_ StandardDG_10_n_ StandardDG_11_n_ 
	foreach var in `varlist' {
		gen rel_`var' = `var'/obs_stDG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	

	rename DGouts~_1_n_  DGoutsideoption9_pass_n_
	rename DGouts~_2_n_  DGoutsideoption9_1_n_
	rename DGoutsi~3_n_  DGoutsideoption9_2_n_
	rename DGoutsi~4_n_  DGoutsideoption9_3_n_
	rename DGoutsi~5_n_  DGoutsideoption9_4_n_
	rename DGoutsi~6_n_  DGoutsideoption9_5_n_
	rename DGoutsi~7_n_  DGoutsideoption9_6_n_
	rename DGoutsi~8_n_  DGoutsideoption9_7_n_
	rename DGoutsi~9_n_  DGoutsideoption9_8_n_
	rename DGoutsi~10_n_  DGoutsideoption9_9_n_
	rename DGouts~11_n_  DGoutsideoption9_10_n_
	rename DGouts~12_n_  DGoutsideoption9_11_n_
	
	local varlist  DGoutsideoption9_pass_n_ DGoutsideoption9_1_n_ DGoutsideoption9_2_n_ DGoutsideoption9_3_n_ DGoutsideoption9_4_n_ DGoutsideoption9_5_n_ DGoutsideoption9_6_n_ DGoutsideoption9_7_n_ DGoutsideoption9_8_n_ DGoutsideoption9_9_n_ DGoutsideoption9_10_n_ DGoutsideoption9_11_n_ 
	foreach var in `varlist' {
	
		gen rel_`var' = `var'/obs_o9DG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	
	ds mean* hi* low* sd*
		
	#d ; 
	collapse (first)   mean_S~_1_n_  mean_St~8_n_  mean_DG~3_n_  mean_DG~0_n_  hi_Stan~6_n_  hi_DGo~_1_n_  hi_DGou~8_n_  low_Sta~4_n_  low_St~11_n_  low_DGo~6_n_  sd_Stan~2_n_  sd_Stan~9_n_  sd_DGou~4_n_  sd_DGo~11_n_ mean_St~2_n_  mean_St~9_n_  mean_DG~4_n_  mean_D~11_n_  hi_Stan~7_n_  hi_DGou~2_n_  hi_DGou~9_n_  low_Sta~5_n_  low_DGo~s_n_  low_DGo~7_n_  sd_Stan~3_n_  sd_Stan~0_n_  sd_DGou~5_n_ mean_St~3_n_  mean_St~0_n_  mean_DG~5_n_  hi_Sta~_1_n_  hi_Stan~8_n_  hi_DGou~3_n_  hi_DGou~0_n_  low_Sta~6_n_  low_DG~_1_n_  low_DGo~8_n_  sd_Stan~4_n_  sd_Sta~11_n_  sd_DGou~6_n_ mean_St~4_n_  mean_S~11_n_  mean_DG~6_n_  hi_Stan~2_n_  hi_Stan~9_n_  hi_DGou~4_n_  hi_DGo~11_n_  low_Sta~7_n_  low_DGo~2_n_  low_DGo~9_n_  sd_Stan~5_n_  sd_DGou~s_n_  sd_DGou~7_n_ mean_St~5_n_  mean_DG~s_n_  mean_DG~7_n_  hi_Stan~3_n_  hi_Stan~0_n_  hi_DGou~5_n_  low_St~_1_n_  low_Sta~8_n_  low_DGo~3_n_  low_DGo~0_n_  sd_Stan~6_n_  sd_DGo~_1_n_  sd_DGou~8_n_ mean_St~6_n_  mean_D~_1_n_  mean_DG~8_n_  hi_Stan~4_n_  hi_Sta~11_n_  hi_DGou~6_n_  low_Sta~2_n_  low_Sta~9_n_  low_DGo~4_n_  low_DG~11_n_  sd_Stan~7_n_  sd_DGou~2_n_  sd_DGou~9_n_ mean_St~7_n_  mean_DG~2_n_  mean_DG~9_n_  hi_Stan~5_n_  hi_DGou~s_n_  hi_DGou~7_n_  low_Sta~3_n_  low_Sta~0_n_  low_DGo~5_n_  sd_Sta~_1_n_  sd_Stan~8_n_  sd_DGou~3_n_  sd_DGou~0_n_
						, by(obs_o9DG)
						; 
	
	#d cr
	

	
	reshape long mean_StandardDG_@_n_ sd_StandardDG_@_n_ hi_StandardDG_@_n_ low_StandardDG_@_n_ mean_DGoutsideoption9_@_n_ sd_DGoutsideoption9_@_n_ hi_DGoutsideoption9_@_n_ low_DGoutsideoption9_@_n_ , i(obs_o9DG) j(payoff)
	
	replace payoff = payoff-1
	
	graph twoway (line mean_StandardDG__n_ payoff) ||  (rcap  hi_StandardDG__n_ low_StandardDG__n_ payoff)  ///
	|| (line mean_DGoutsideoption9__n_ payoff) || (rcap  hi_DGoutsideoption9__n_ low_DGoutsideoption9__n_ payoff) ///
	|| (scatter mean_DGoutsideoption9_pass_n_ payoff if payoff ==0 ) || (rcap  hi_DGoutsideoption9_pass_n_ low_DGoutsideoption9_pass_n_ payoff if payoff ==0) , ///
	ytitle("Average rating") title("Standard DG and DG with exit option") sub("Social appropriateness") xlabel(#10) ylabel(#5) yscale( r(-1/1)) graphregion(color(white)) bgcolor(white) 	legend(size(vsmall) pos(6)   lab(1 "Standard DG") lab(2 "CI (5% level) St. DG") lab(3 "DG with exit option") lab(4 "CI (5% level) DG with exit") lab(5 "DG with exit - pass") lab(6 "CI (5% level) DG pass") stack) 
	graph export "$mainpath/exitDG.png", replace
	
restore


****				   
* DG standard, take1, take 5
preserve

	local varlist StandardDG_1_n StandardDG_2_n StandardDG_3_n StandardDG_4_n StandardDG_5_n StandardDG_6_n StandardDG_7_n StandardDG_8_n StandardDG_9_n StandardDG_10_n StandardDG_11_n ///
	    DGtake1_1_n DGtake1_2_n DGtake1_3_n DGtake1_4_n DGtake1_5_n DGtake1_6_n DGtake1_8_n DGtake1_9_n DGtake1_10_n DGtake1_11_n DGtake1_12_n DGtake1_13_n ///
		DGtake5_1_n DGtake5_2_n DGtake5_3_n DGtake5_4_n DGtake5_5_n DGtake5_6_n DGtake5_7_n DGtake5_8_n DGtake5_9_n DGtake5_10_n DGtake5_12_n DGtake5_14_n DGtake5_16_n DGtake5_18_n DGtake5_20_n DGtake5_21_n

	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if `var' !=.
		gen `var'_2 = (`var'==-0.5) if `var' !=.
		gen `var'_3 = (`var'==0) if `var' !=.
		gen `var'_4 = (`var'==0.5) if `var' !=.
		gen `var'_5 = (`var'==1)  if `var' !=.
		
	}
	
	gen obs_stDG = _n if StandardDG_1_n !=.
	gen obs_t1DG = _n if DGtake1_1_n !=.
	gen obs_t5DG = _n if DGtake5_1_n !=.

	reshape long  StandardDG_1_n_@ StandardDG_2_n_@ StandardDG_3_n_@ StandardDG_4_n_@ StandardDG_5_n_@ StandardDG_6_n_@ StandardDG_7_n_@ StandardDG_8_n_@ StandardDG_9_n_@ StandardDG_10_n_@ StandardDG_11_n_@  DGtake1_1_n_@ DGtake1_2_n_@ DGtake1_3_n_@ DGtake1_4_n_@ DGtake1_5_n_@ DGtake1_6_n_@ DGtake1_7_n_@  DGtake1_8_n_@ DGtake1_9_n_@ DGtake1_10_n_@ DGtake1_11_n_@ DGtake1_12_n_@ DGtake1_13_n_@ DGtake5_1_n_@ DGtake5_2_n_@ DGtake5_3_n_@ DGtake5_4_n_@ DGtake5_5_n_@ DGtake5_6_n_@ DGtake5_7_n_@ DGtake5_8_n_@ DGtake5_9_n_@ DGtake5_10_n_@ DGtake5_11_n_@ DGtake5_12_n_@ DGtake5_13_n_@ DGtake5_14_n_@ DGtake5_15_n_@  DGtake5_16_n_@ DGtake5_17_n_@  DGtake5_18_n_@ DGtake5_19_n_@ DGtake5_20_n_@ DGtake5_21_n_@, i(participant_id) j(situation) string 
	
	collapse (count)  obs_stDG obs_t1DG obs_t5DG (sum) StandardDG_1_n_ StandardDG_2_n_ StandardDG_3_n_ StandardDG_4_n_ StandardDG_5_n_ StandardDG_6_n_ StandardDG_7_n_ StandardDG_8_n_ StandardDG_9_n_ StandardDG_10_n_ StandardDG_11_n_  DGtake1_1_n_ DGtake1_2_n_ DGtake1_3_n_ DGtake1_4_n_ DGtake1_5_n_ DGtake1_6_n_ DGtake1_7_n_  DGtake1_8_n_ DGtake1_9_n_ DGtake1_10_n_ DGtake1_11_n_ DGtake1_12_n_ DGtake1_13_n_ DGtake5_1_n_ DGtake5_2_n_ DGtake5_3_n_ DGtake5_4_n_ DGtake5_5_n_ DGtake5_6_n_ DGtake5_7_n_ DGtake5_8_n_ DGtake5_9_n_ DGtake5_10_n_ DGtake5_11_n_ DGtake5_12_n_ DGtake5_13_n_ DGtake5_14_n_ DGtake5_15_n_   DGtake5_16_n_ DGtake5_17_n_  DGtake5_18_n_ DGtake5_19_n_ DGtake5_20_n_ DGtake5_21_n_, by(situation)
	
	destring situation, replace 
	replace situation = -1   if situation ==1 
	replace situation = -0.5 if situation ==2
	replace situation = 0    if situation ==3 
	replace situation = -0.5 if situation ==4
	replace situation = 1    if situation ==5	
	
	rename StandardDG_1_n_  StandardDG_0_n_
	rename StandardDG_2_n_  StandardDG_1_n_
	rename StandardDG_3_n_  StandardDG_2_n_
	rename StandardDG_4_n_  StandardDG_3_n_
	rename StandardDG_5_n_  StandardDG_4_n_
	rename StandardDG_6_n_  StandardDG_5_n_
	rename StandardDG_7_n_  StandardDG_6_n_
	rename StandardDG_8_n_  StandardDG_7_n_
	rename StandardDG_9_n_  StandardDG_8_n_
	rename StandardDG_10_n_  StandardDG_9_n_
	rename StandardDG_11_n_  StandardDG_10_n_
		
	local varlist StandardDG_0_n_ StandardDG_1_n_ StandardDG_2_n_ StandardDG_3_n_ StandardDG_4_n_ StandardDG_5_n_ StandardDG_6_n_ StandardDG_7_n_ StandardDG_8_n_ StandardDG_9_n_ StandardDG_10_n_ 
	foreach var in `varlist' {
		gen rel_`var' = `var'/obs_stDG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	

	rename DGtake1_1_n_  DGtake1_m2_n_
	rename DGtake1_2_n_  DGtake1_m1_n_
	rename DGtake1_3_n_  DGtake1_0_n_
	rename DGtake1_4_n_  DGtake1_1_n_
	rename DGtake1_5_n_  DGtake1_2_n_
	rename DGtake1_6_n_  DGtake1_3_n_
	rename DGtake1_7_n_  DGtake1_4_n_
	rename DGtake1_8_n_  DGtake1_5_n_
	rename DGtake1_9_n_  DGtake1_6_n_
	rename DGtake1_10_n_ DGtake1_7_n_
	rename DGtake1_11_n_ DGtake1_8_n_
	rename DGtake1_12_n_ DGtake1_9_n_
	rename DGtake1_13_n_ DGtake1_10_n_
	rename DGtake5_1_n_  DGtake5_m10_n_
	rename DGtake5_2_n_  DGtake5_m9_n_
	rename DGtake5_3_n_  DGtake5_m8_n_
	rename DGtake5_4_n_  DGtake5_m7_n_
	rename DGtake5_5_n_  DGtake5_m6_n_
	rename DGtake5_6_n_  DGtake5_m5_n_
	rename DGtake5_7_n_  DGtake5_m4_n_
	rename DGtake5_8_n_  DGtake5_m3_n_
	rename DGtake5_9_n_  DGtake5_m2_n_
	rename DGtake5_10_n_ DGtake5_m1_n_
	rename DGtake5_11_n_ DGtake5_0_n_
	rename DGtake5_12_n_ DGtake5_1_n_
	rename DGtake5_13_n_ DGtake5_2_n_
	rename DGtake5_14_n_ DGtake5_3_n_
	rename DGtake5_15_n_ DGtake5_4_n_
	rename DGtake5_16_n_ DGtake5_5_n_
	rename DGtake5_17_n_ DGtake5_6_n_
	rename DGtake5_18_n_ DGtake5_7_n_
	rename DGtake5_19_n_ DGtake5_8_n_
	rename DGtake5_20_n_ DGtake5_9_n_
	rename DGtake5_21_n_ DGtake5_10_n_
	
	local varlist   DGtake1_m2_n_ DGtake1_m1_n_ DGtake1_0_n_ DGtake1_1_n_ DGtake1_2_n_ DGtake1_3_n_ DGtake1_4_n_ DGtake1_5_n_ DGtake1_6_n_ DGtake1_7_n_  DGtake1_8_n_ DGtake1_9_n_ DGtake1_10_n_  
	foreach var in `varlist' {
	
		gen rel_`var' = `var'/obs_t1DG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	
	local varlist  DGtake5_m10_n_ DGtake5_m9_n_ DGtake5_m8_n_ DGtake5_m7_n_ DGtake5_m6_n_ DGtake5_m5_n_ DGtake5_m4_n_ DGtake5_m3_n_ DGtake5_m2_n_ DGtake5_m1_n_ DGtake5_0_n_ DGtake5_1_n_ DGtake5_2_n_ DGtake5_3_n_ DGtake5_4_n_ DGtake5_5_n_ DGtake5_6_n_ DGtake5_7_n_  DGtake5_8_n_ DGtake5_9_n_ DGtake5_10_n_ 
		foreach var in `varlist' {
	
		gen rel_`var' = `var'/obs_t5DG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	
	ds mean* hi* low* sd*
		
	#d ; 
	collapse (first) mean_S~_0_n_  mean_~1_5_n_  mean_~5_2_n_  hi_Stan~9_n_  hi_DGt~m7_n_  low_St~_0_n_  low_D~1_5_n_  low_D~5_2_n_  sd_Stan~9_n_  sd_DGt~m7_n_
					mean_St~1_n_  mean_~1_6_n_  mean_~5_3_n_  hi_Sta~10_n_  hi_DGt~m6_n_  low_Sta~1_n_  low_D~1_6_n_  low_D~5_3_n_  sd_Sta~10_n_  sd_DGt~m6_n_
					mean_St~2_n_  mean_~1_7_n_  mean_~5_4_n_  hi_D~1_m2_n_  hi_DGt~m5_n_  low_Sta~2_n_  low_D~1_7_n_  low_D~5_4_n_  sd_D~1_m2_n_  sd_DGt~m5_n_
					mean_St~3_n_  mean_~1_8_n_  mean_~5_5_n_  hi_D~1_m1_n_  hi_DGt~m4_n_  low_Sta~3_n_  low_D~1_8_n_  low_D~5_5_n_  sd_D~1_m1_n_  sd_DGt~m4_n_
					mean_St~4_n_  mean_~1_9_n_  mean_~5_6_n_  hi_DG~1_0_n_  hi_DGt~m3_n_  low_Sta~4_n_  low_D~1_9_n_  low_D~5_6_n_  sd_DG~1_0_n_  sd_DGt~m3_n_
					mean_St~5_n_  mean~1_10_n_  mean_~5_7_n_  hi_DG~1_1_n_  hi_D~5_m2_n_  low_Sta~5_n_  low_~1_10_n_  low_D~5_7_n_  sd_DG~1_1_n_  sd_D~5_m2_n_
					mean_St~6_n_  mean_~m10_n_  mean_~5_8_n_  hi_DG~1_2_n_  hi_D~5_m1_n_  low_Sta~6_n_  low_D~m10_n_  low_D~5_8_n_  sd_DG~1_2_n_  sd_D~5_m1_n_
					mean_St~7_n_  mean_D~m9_n_  mean_~5_9_n_  hi_DG~1_3_n_  hi_DG~5_0_n_  low_Sta~7_n_  low_DG~m9_n_  low_D~5_9_n_  sd_DG~1_3_n_  sd_DG~5_0_n_
					mean_St~8_n_  mean_D~m8_n_  mean~5_10_n_  hi_DG~1_4_n_  hi_DG~5_1_n_  low_Sta~8_n_  low_DG~m8_n_  low_~5_10_n_  sd_DG~1_4_n_  sd_DG~5_1_n_
					mean_St~9_n_  mean_D~m7_n_  hi_Sta~_0_n_  hi_DG~1_5_n_  hi_DG~5_2_n_  low_Sta~9_n_  low_DG~m7_n_  sd_Sta~_0_n_  sd_DG~1_5_n_  sd_DG~5_2_n_
					mean_S~10_n_  mean_D~m6_n_  hi_Stan~1_n_  hi_DG~1_6_n_  hi_DG~5_3_n_  low_St~10_n_  low_DG~m6_n_  sd_Stan~1_n_  sd_DG~1_6_n_  sd_DG~5_3_n_
					mean~1_m2_n_  mean_D~m5_n_  hi_Stan~2_n_  hi_DG~1_7_n_  hi_DG~5_4_n_  low_~1_m2_n_  low_DG~m5_n_  sd_Stan~2_n_  sd_DG~1_7_n_  sd_DG~5_4_n_
					mean~1_m1_n_  mean_D~m4_n_  hi_Stan~3_n_  hi_DG~1_8_n_  hi_DG~5_5_n_  low_~1_m1_n_  low_DG~m4_n_  sd_Stan~3_n_  sd_DG~1_8_n_  sd_DG~5_5_n_
					mean_~1_0_n_  mean_D~m3_n_  hi_Stan~4_n_  hi_DG~1_9_n_  hi_DG~5_6_n_  low_D~1_0_n_  low_DG~m3_n_  sd_Stan~4_n_  sd_DG~1_9_n_  sd_DG~5_6_n_
					mean_~1_1_n_  mean~5_m2_n_  hi_Stan~5_n_  hi_D~1_10_n_  hi_DG~5_7_n_  low_D~1_1_n_  low_~5_m2_n_  sd_Stan~5_n_  sd_D~1_10_n_  sd_DG~5_7_n_
					mean_~1_2_n_  mean~5_m1_n_  hi_Stan~6_n_  hi_DG~m10_n_  hi_DG~5_8_n_  low_D~1_2_n_  low_~5_m1_n_  sd_Stan~6_n_  sd_DG~m10_n_  sd_DG~5_8_n_
					mean_~1_3_n_  mean_~5_0_n_  hi_Stan~7_n_  hi_DGt~m9_n_  hi_DG~5_9_n_  low_D~1_3_n_  low_D~5_0_n_  sd_Stan~7_n_  sd_DGt~m9_n_  sd_DG~5_9_n_
					mean_~1_4_n_  mean_~5_1_n_  hi_Stan~8_n_  hi_DGt~m8_n_  hi_D~5_10_n_  low_D~1_4_n_  low_D~5_1_n_  sd_Stan~8_n_  sd_DGt~m8_n_  sd_D~5_10_n_
						, by(obs_stDG)
						; 
	
	#d cr
	

	reshape long mean_StandardDG_@_n_ sd_StandardDG_@_n_ hi_StandardDG_@_n_ low_StandardDG_@_n_ mean_DGtake1_@_n_ sd_DGtake1_@_n_ hi_DGtake1_@_n_ low_DGtake1_@_n_ mean_DGtake5_@_n_ sd_DGtake5_@_n_ hi_DGtake5_@_n_ low_DGtake5_@_n_ , i(obs_stDG) j(payoff) string
	
	replace payoff = subinstr(payoff, "m", "-", . )
	destring payoff, replace
	sort payoff
	
	graph twoway (line mean_StandardDG__n_ payoff) ||  (rcap  hi_StandardDG__n_ low_StandardDG__n_ payoff, )  ///
	|| (line mean_DGtake1__n_ payoff) || (rcap  hi_DGtake1__n_ low_DGtake1__n_ payoff ) ///
	|| (line mean_DGtake5__n_ payoff) || (rcap  hi_DGtake5__n_ low_DGtake5__n_ payoff) ,  ///
	ytitle("Average rating") title("Standard DG and DG with take 1 and take 5 option") sub("Social appropriateness") xlabel(#20) ylabel(#5) yscale( r(-1/1)) graphregion(color(white)) bgcolor(white) 	legend(size(vsmall) pos(6)   lab(1 "Standard DG") lab(2 "CI (5% level) St. DG") lab(3 "DG take 1") lab(4 "CI (5% level) DG take 1") lab(5 "DG take 5") lab(6 "CI (5% level) DG take 5") stack) 
	graph export "$mainpath/takeDG.png", replace
	
restore


****				   
* DG with surplus generation
preserve 

	local varlist StandardDG_1_n StandardDG_2_n StandardDG_3_n StandardDG_4_n StandardDG_5_n StandardDG_6_n StandardDG_7_n StandardDG_8_n StandardDG_9_n StandardDG_10_n StandardDG_11_n ///
	    DGQuiz_1_n DGQuiz_2_n DGQuiz_5_n DGQuiz_6_n DGQuiz_7_n DGQuiz_8_n DGQuiz_9_n DGQuiz_10_n DGQuiz_11_n DGProduction_1_n DGProduction_2_n DGProduction_4_n DGProduction_5_n DGProduction_6_n DGProduction_9_n DGProduction_10_n DGProduction_11_n
	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if `var' !=.
		gen `var'_2 = (`var'==-0.5) if `var' !=.
		gen `var'_3 = (`var'==0) if `var' !=.
		gen `var'_4 = (`var'==0.5) if `var' !=.
		gen `var'_5 = (`var'==1)  if `var' !=.
		
	}
	
	gen obs_stDG = _n if StandardDG_1_n !=.
	gen obs_qDG = _n if DGQuiz_1_n !=.
	gen obs_pDG = _n if DGProduction_1_n !=.

	reshape long  StandardDG_1_n_@ StandardDG_2_n_@ StandardDG_3_n_@ StandardDG_4_n_@ StandardDG_5_n_@ StandardDG_6_n_@ StandardDG_7_n_@ StandardDG_8_n_@ StandardDG_9_n_@ StandardDG_10_n_@ StandardDG_11_n_@ ///
	    DGQuiz_1_n_@ DGQuiz_2_n_@ DGQuiz_5_n_@ DGQuiz_6_n_@ DGQuiz_7_n_@ DGQuiz_8_n_@ DGQuiz_9_n_@ DGQuiz_10_n_@ DGQuiz_11_n_@ DGProduction_1_n_@ DGProduction_2_n_@ DGProduction_4_n_@ DGProduction_5_n_@ DGProduction_6_n_@ DGProduction_9_n_@ DGProduction_10_n_@ DGProduction_11_n_@ , i(participant_id) j(situation) string 
	
	collapse (count)  obs_stDG obs_qDG obs_pDG (sum) StandardDG_1_n_ StandardDG_2_n_ StandardDG_3_n_ StandardDG_4_n_ StandardDG_5_n_ StandardDG_6_n_ StandardDG_7_n_ StandardDG_8_n_ StandardDG_9_n_ StandardDG_10_n_ StandardDG_11_n_  DGQuiz_1_n_ DGQuiz_2_n_ DGQuiz_5_n_ DGQuiz_6_n_ DGQuiz_7_n_ DGQuiz_8_n_ DGQuiz_9_n_ DGQuiz_10_n_ DGQuiz_11_n_ DGProduction_1_n_ DGProduction_2_n_ DGProduction_4_n_ DGProduction_5_n_ DGProduction_6_n_ DGProduction_9_n_ DGProduction_10_n_ DGProduction_11_n_ , by(situation)
	
	destring situation, replace 
	replace situation = -1   if situation ==1 
	replace situation = -0.5 if situation ==2
	replace situation = 0    if situation ==3 
	replace situation = -0.5 if situation ==4
	replace situation = 1    if situation ==5	
	

		
	local varlist StandardDG_11_n_ StandardDG_1_n_ StandardDG_2_n_ StandardDG_3_n_ StandardDG_4_n_ StandardDG_5_n_ StandardDG_6_n_ StandardDG_7_n_ StandardDG_8_n_ StandardDG_9_n_ StandardDG_10_n_ 
	foreach var in `varlist' {
		gen rel_`var' = `var'/obs_stDG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	
	
	local varlist   DGQuiz_1_n_ DGQuiz_2_n_ DGQuiz_5_n_ DGQuiz_6_n_ DGQuiz_7_n_ DGQuiz_8_n_ DGQuiz_9_n_ DGQuiz_10_n_ DGQuiz_11_n_ 
	foreach var in `varlist' {
	
		gen rel_`var' = `var'/obs_qDG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	
	local varlist  DGProduction_1_n_ DGProduction_2_n_ DGProduction_4_n_ DGProduction_5_n_ DGProduction_6_n_ DGProduction_9_n_ DGProduction_10_n_ DGProduction_11_n_ 
		foreach var in `varlist' {
	
		gen rel_`var' = `var'/obs_pDG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	
	ds mean* hi* low* sd*
		
	#d ; 
	collapse (first) mean_S~_1_n_  mean_~z_2_n_  mean_~n_6_n_  hi_Stan~9_n_  hi_DGP~_1_n_  low_Sta~5_n_  low_DGQ~8_n_  sd_Sta~_1_n_  sd_DGQu~2_n_  sd_DGPr~6_n_
					mean_St~2_n_  mean_~z_5_n_  mean_~n_9_n_  hi_Stan~0_n_  hi_DGPr~2_n_  low_Sta~6_n_  low_DGQ~9_n_  sd_Stan~2_n_  sd_DGQu~5_n_  sd_DGPr~9_n_
					mean_St~3_n_  mean_~z_6_n_  mean~n_10_n_  hi_Sta~11_n_  hi_DGPr~4_n_  low_Sta~7_n_  low_DGQ~0_n_  sd_Stan~3_n_  sd_DGQu~6_n_  sd_DGPr~0_n_
					mean_St~4_n_  mean_DG~7_n_  mean~n_11_n_  hi_DGQ~_1_n_  hi_DGPr~5_n_  low_Sta~8_n_  low_~z_11_n_  sd_Stan~4_n_  sd_DGQu~7_n_  sd_DGP~11_n_
					mean_St~5_n_  mean_DG~8_n_  hi_Sta~_1_n_  hi_DGQu~2_n_  hi_DGPr~6_n_  low_Sta~9_n_  low_D~n_1_n_  sd_Stan~5_n_  sd_DGQu~8_n_
					mean_St~6_n_  mean_~z_9_n_  hi_Stan~2_n_  hi_DGQu~5_n_  hi_DGPr~9_n_  low_Sta~0_n_  low_DGP~2_n_  sd_Stan~6_n_  sd_DGQu~9_n_
					mean_St~7_n_  mean~z_10_n_  hi_Stan~3_n_  hi_DGQu~6_n_  hi_DGPr~0_n_  low_St~11_n_  low_DGP~4_n_  sd_Stan~7_n_  sd_DGQu~0_n_
					mean_St~8_n_  mean~z_11_n_  hi_Stan~4_n_  hi_DGQu~7_n_  hi_DGP~11_n_  low_D~z_1_n_  low_DGP~5_n_  sd_Stan~8_n_  sd_DGQ~11_n_
					mean_St~9_n_  mean_~n_1_n_  hi_Stan~5_n_  hi_DGQu~8_n_  low_St~_1_n_  low_DGQ~2_n_  low_DGP~6_n_  sd_Stan~9_n_  sd_DGP~_1_n_
					mean_St~0_n_  mean_~n_2_n_  hi_Stan~6_n_  hi_DGQu~9_n_  low_Sta~2_n_  low_DGQ~5_n_  low_DGP~9_n_  sd_Stan~0_n_  sd_DGPr~2_n_
					mean_S~11_n_  mean_DG~4_n_  hi_Stan~7_n_  hi_DGQu~0_n_  low_Sta~3_n_  low_DGQ~6_n_  low_DGP~0_n_  sd_Sta~11_n_  sd_DGPr~4_n_
					mean_~z_1_n_  mean_~n_5_n_  hi_Stan~8_n_  hi_DGQ~11_n_  low_Sta~4_n_  low_DGQ~7_n_  low_~n_11_n_  sd_DGQ~_1_n_  sd_DGPr~5_n_
						, by(obs_stDG)
						; 
	
	#d cr
	

	reshape long mean_StandardDG_@_n_ sd_StandardDG_@_n_ hi_StandardDG_@_n_ low_StandardDG_@_n_ mean_DGQuiz_@_n_ sd_DGQuiz_@_n_ hi_DGQuiz_@_n_ low_DGQuiz_@_n_ mean_DGProduction_@_n_ sd_DGProduction_@_n_ hi_DGProduction_@_n_ low_DGProduction_@_n_ , i(obs_stDG) j(payoff) 
	
	replace payoff = payoff-1
	
	
	graph twoway (line mean_StandardDG__n_ payoff) ||  (rcap  hi_StandardDG__n_ low_StandardDG__n_ payoff, )  ///
	|| (line mean_DGQuiz__n_ payoff) || (rcap  hi_DGQuiz__n_ low_DGQuiz__n_ payoff ) ///
	|| (line mean_DGProduction__n_ payoff) || (rcap  hi_DGProduction__n_ low_DGProduction__n_ payoff) ,  ///
	ytitle("Average rating") title("Standard DG and DG with take 1 and take 5 option") sub("Social appropriateness") xlabel(#20) ylabel(#5) yscale( r(-1/1)) graphregion(color(white)) bgcolor(white) 	legend(size(vsmall) pos(6)   lab(1 "Standard DG") lab(2 "CI (5% level) St. DG") lab(3 "DG quiz") lab(4 "CI (5% level) DG quiz") lab(5 "DG production") lab(6 "CI (5% level) DG production") stack) 
	graph export "$mainpath/surplusDG.png", replace
	
restore

               ** PERSONAL APPROPRIATENESS **

use "$mainpath/MultiplesGamesElicitation_Pers_cleaned.dta", clear 			   
	
* DG standard and exit option (figura 1) 
preserve

	local varlist StandardDG_1_n StandardDG_2_n StandardDG_3_n StandardDG_4_n StandardDG_5_n StandardDG_6_n StandardDG_7_n StandardDG_8_n StandardDG_9_n StandardDG_10_n StandardDG_11_n ///
	              DGoutsideoption9_1_n DGoutsideoption9_2_n DGoutsideoption9_3_n DGoutsideoption9_4_n DGoutsideoption9_5_n DGoutsideoption9_6_n DGoutsideoption9_7_n DGoutsideoption9_8_n DGoutsideoption9_9_n DGoutsideoption9_10_n DGoutsideoption9_11_n DGoutsideoption9_12_n
	
	
	
	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if `var' !=.
		gen `var'_2 = (`var'==-0.5) if `var' !=.
		gen `var'_3 = (`var'==0) if `var' !=.
		gen `var'_4 = (`var'==0.5) if `var' !=.
		gen `var'_5 = (`var'==1)  if `var' !=.
		
	}
	
	gen obs_stDG = _n if StandardDG_1_n !=.
	gen obs_o9DG = _n if DGoutsideoption9_1_n !=.

	reshape long  StandardDG_1_n_@ StandardDG_2_n_@ StandardDG_3_n_@ StandardDG_4_n_@ StandardDG_5_n_@ StandardDG_6_n_@ StandardDG_7_n_@ StandardDG_8_n_@ StandardDG_9_n_@ StandardDG_10_n_@ StandardDG_11_n_@ DGoutsideoption9_1_n_@ DGoutsideoption9_2_n_@ DGoutsideoption9_3_n_@ DGoutsideoption9_4_n_@ DGoutsideoption9_5_n_@ DGoutsideoption9_6_n_@ DGoutsideoption9_7_n_@ DGoutsideoption9_8_n_@ DGoutsideoption9_9_n_@ DGoutsideoption9_10_n_@ DGoutsideoption9_11_n_@ DGoutsideoption9_12_n_@, i(participant_id) j(situation) string 
	
	collapse (count)  obs_stDG obs_o9DG (sum) StandardDG_1_n_ StandardDG_2_n_ StandardDG_3_n_ StandardDG_4_n_ StandardDG_5_n_ StandardDG_6_n_ StandardDG_7_n_ StandardDG_8_n_ StandardDG_9_n_ StandardDG_10_n_ StandardDG_11_n_ DGoutsideoption9_1_n_ DGoutsideoption9_2_n_ DGoutsideoption9_3_n_ DGoutsideoption9_4_n_ DGoutsideoption9_5_n_ DGoutsideoption9_6_n_ DGoutsideoption9_7_n_ DGoutsideoption9_8_n_ DGoutsideoption9_9_n_ DGoutsideoption9_10_n_ DGoutsideoption9_11_n_ DGoutsideoption9_12_n_, by(situation)
	
	destring situation, replace 
	replace situation = -1   if situation ==1 
	replace situation = -0.5 if situation ==2
	replace situation = 0    if situation ==3 
	replace situation = -0.5 if situation ==4
	replace situation = 1    if situation ==5	
		
	local varlist StandardDG_1_n_ StandardDG_2_n_ StandardDG_3_n_ StandardDG_4_n_ StandardDG_5_n_ StandardDG_6_n_ StandardDG_7_n_ StandardDG_8_n_ StandardDG_9_n_ StandardDG_10_n_ StandardDG_11_n_ 
	foreach var in `varlist' {
		gen rel_`var' = `var'/obs_stDG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	

	rename DGouts~_1_n_  DGoutsideoption9_pass_n_
	rename DGouts~_2_n_  DGoutsideoption9_1_n_
	rename DGoutsi~3_n_  DGoutsideoption9_2_n_
	rename DGoutsi~4_n_  DGoutsideoption9_3_n_
	rename DGoutsi~5_n_  DGoutsideoption9_4_n_
	rename DGoutsi~6_n_  DGoutsideoption9_5_n_
	rename DGoutsi~7_n_  DGoutsideoption9_6_n_
	rename DGoutsi~8_n_  DGoutsideoption9_7_n_
	rename DGoutsi~9_n_  DGoutsideoption9_8_n_
	rename DGoutsi~10_n_  DGoutsideoption9_9_n_
	rename DGouts~11_n_  DGoutsideoption9_10_n_
	rename DGouts~12_n_  DGoutsideoption9_11_n_
	
	local varlist  DGoutsideoption9_pass_n_ DGoutsideoption9_1_n_ DGoutsideoption9_2_n_ DGoutsideoption9_3_n_ DGoutsideoption9_4_n_ DGoutsideoption9_5_n_ DGoutsideoption9_6_n_ DGoutsideoption9_7_n_ DGoutsideoption9_8_n_ DGoutsideoption9_9_n_ DGoutsideoption9_10_n_ DGoutsideoption9_11_n_ 
	foreach var in `varlist' {
	
		gen rel_`var' = `var'/obs_o9DG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	
	ds mean* hi* low* sd*
		
	#d ; 
	collapse (first)   mean_S~_1_n_  mean_St~8_n_  mean_DG~3_n_  mean_DG~0_n_  hi_Stan~6_n_  hi_DGo~_1_n_  hi_DGou~8_n_  low_Sta~4_n_  low_St~11_n_  low_DGo~6_n_  sd_Stan~2_n_  sd_Stan~9_n_  sd_DGou~4_n_  sd_DGo~11_n_ mean_St~2_n_  mean_St~9_n_  mean_DG~4_n_  mean_D~11_n_  hi_Stan~7_n_  hi_DGou~2_n_  hi_DGou~9_n_  low_Sta~5_n_  low_DGo~s_n_  low_DGo~7_n_  sd_Stan~3_n_  sd_Stan~0_n_  sd_DGou~5_n_ mean_St~3_n_  mean_St~0_n_  mean_DG~5_n_  hi_Sta~_1_n_  hi_Stan~8_n_  hi_DGou~3_n_  hi_DGou~0_n_  low_Sta~6_n_  low_DG~_1_n_  low_DGo~8_n_  sd_Stan~4_n_  sd_Sta~11_n_  sd_DGou~6_n_ mean_St~4_n_  mean_S~11_n_  mean_DG~6_n_  hi_Stan~2_n_  hi_Stan~9_n_  hi_DGou~4_n_  hi_DGo~11_n_  low_Sta~7_n_  low_DGo~2_n_  low_DGo~9_n_  sd_Stan~5_n_  sd_DGou~s_n_  sd_DGou~7_n_ mean_St~5_n_  mean_DG~s_n_  mean_DG~7_n_  hi_Stan~3_n_  hi_Stan~0_n_  hi_DGou~5_n_  low_St~_1_n_  low_Sta~8_n_  low_DGo~3_n_  low_DGo~0_n_  sd_Stan~6_n_  sd_DGo~_1_n_  sd_DGou~8_n_ mean_St~6_n_  mean_D~_1_n_  mean_DG~8_n_  hi_Stan~4_n_  hi_Sta~11_n_  hi_DGou~6_n_  low_Sta~2_n_  low_Sta~9_n_  low_DGo~4_n_  low_DG~11_n_  sd_Stan~7_n_  sd_DGou~2_n_  sd_DGou~9_n_ mean_St~7_n_  mean_DG~2_n_  mean_DG~9_n_  hi_Stan~5_n_  hi_DGou~s_n_  hi_DGou~7_n_  low_Sta~3_n_  low_Sta~0_n_  low_DGo~5_n_  sd_Sta~_1_n_  sd_Stan~8_n_  sd_DGou~3_n_  sd_DGou~0_n_
						, by(obs_o9DG)
						; 
	
	#d cr
	

	
	reshape long mean_StandardDG_@_n_ sd_StandardDG_@_n_ hi_StandardDG_@_n_ low_StandardDG_@_n_ mean_DGoutsideoption9_@_n_ sd_DGoutsideoption9_@_n_ hi_DGoutsideoption9_@_n_ low_DGoutsideoption9_@_n_ , i(obs_o9DG) j(payoff)
	
	replace payoff = payoff-1
	
	graph twoway (line mean_StandardDG__n_ payoff) ||  (rcap  hi_StandardDG__n_ low_StandardDG__n_ payoff)  ///
	|| (line mean_DGoutsideoption9__n_ payoff) || (rcap  hi_DGoutsideoption9__n_ low_DGoutsideoption9__n_ payoff) ///
	|| (scatter mean_DGoutsideoption9_pass_n_ payoff if payoff ==0 ) || (rcap  hi_DGoutsideoption9_pass_n_ low_DGoutsideoption9_pass_n_ payoff if payoff ==0) , ///
	ytitle("Average rating") title("Standard DG and DG with exit option") sub("Personal appropriateness") xlabel(#10) ylabel(#5) yscale( r(-1/1)) graphregion(color(white)) bgcolor(white) 	legend(size(vsmall) pos(6)   lab(1 "Standard DG") lab(2 "CI (5% level) St. DG") lab(3 "DG with exit option") lab(4 "CI (5% level) DG with exit") lab(5 "DG with exit - pass") lab(6 "CI (5% level) DG pass") stack) 
	graph export "$mainpath/exitDG_personal.png", replace
	
restore


****				   
* DG standard, take1, take 5
preserve

	local varlist StandardDG_1_n StandardDG_2_n StandardDG_3_n StandardDG_4_n StandardDG_5_n StandardDG_6_n StandardDG_7_n StandardDG_8_n StandardDG_9_n StandardDG_10_n StandardDG_11_n ///
	    DGtake1_1_n DGtake1_2_n DGtake1_3_n DGtake1_4_n DGtake1_5_n DGtake1_6_n DGtake1_8_n DGtake1_9_n DGtake1_10_n DGtake1_11_n DGtake1_12_n DGtake1_13_n ///
		DGtake5_1_n DGtake5_2_n DGtake5_3_n DGtake5_4_n DGtake5_5_n DGtake5_6_n DGtake5_7_n DGtake5_8_n DGtake5_9_n DGtake5_10_n DGtake5_12_n DGtake5_14_n DGtake5_16_n DGtake5_18_n DGtake5_20_n DGtake5_21_n

	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if `var' !=.
		gen `var'_2 = (`var'==-0.5) if `var' !=.
		gen `var'_3 = (`var'==0) if `var' !=.
		gen `var'_4 = (`var'==0.5) if `var' !=.
		gen `var'_5 = (`var'==1)  if `var' !=.
		
	}
	
	gen obs_stDG = _n if StandardDG_1_n !=.
	gen obs_t1DG = _n if DGtake1_1_n !=.
	gen obs_t5DG = _n if DGtake5_1_n !=.

	reshape long  StandardDG_1_n_@ StandardDG_2_n_@ StandardDG_3_n_@ StandardDG_4_n_@ StandardDG_5_n_@ StandardDG_6_n_@ StandardDG_7_n_@ StandardDG_8_n_@ StandardDG_9_n_@ StandardDG_10_n_@ StandardDG_11_n_@  DGtake1_1_n_@ DGtake1_2_n_@ DGtake1_3_n_@ DGtake1_4_n_@ DGtake1_5_n_@ DGtake1_6_n_@ DGtake1_7_n_@  DGtake1_8_n_@ DGtake1_9_n_@ DGtake1_10_n_@ DGtake1_11_n_@ DGtake1_12_n_@ DGtake1_13_n_@ DGtake5_1_n_@ DGtake5_2_n_@ DGtake5_3_n_@ DGtake5_4_n_@ DGtake5_5_n_@ DGtake5_6_n_@ DGtake5_7_n_@ DGtake5_8_n_@ DGtake5_9_n_@ DGtake5_10_n_@ DGtake5_11_n_@ DGtake5_12_n_@ DGtake5_13_n_@ DGtake5_14_n_@ DGtake5_15_n_@  DGtake5_16_n_@ DGtake5_17_n_@  DGtake5_18_n_@ DGtake5_19_n_@ DGtake5_20_n_@ DGtake5_21_n_@, i(participant_id) j(situation) string 
	
	collapse (count)  obs_stDG obs_t1DG obs_t5DG (sum) StandardDG_1_n_ StandardDG_2_n_ StandardDG_3_n_ StandardDG_4_n_ StandardDG_5_n_ StandardDG_6_n_ StandardDG_7_n_ StandardDG_8_n_ StandardDG_9_n_ StandardDG_10_n_ StandardDG_11_n_  DGtake1_1_n_ DGtake1_2_n_ DGtake1_3_n_ DGtake1_4_n_ DGtake1_5_n_ DGtake1_6_n_ DGtake1_7_n_  DGtake1_8_n_ DGtake1_9_n_ DGtake1_10_n_ DGtake1_11_n_ DGtake1_12_n_ DGtake1_13_n_ DGtake5_1_n_ DGtake5_2_n_ DGtake5_3_n_ DGtake5_4_n_ DGtake5_5_n_ DGtake5_6_n_ DGtake5_7_n_ DGtake5_8_n_ DGtake5_9_n_ DGtake5_10_n_ DGtake5_11_n_ DGtake5_12_n_ DGtake5_13_n_ DGtake5_14_n_ DGtake5_15_n_   DGtake5_16_n_ DGtake5_17_n_  DGtake5_18_n_ DGtake5_19_n_ DGtake5_20_n_ DGtake5_21_n_, by(situation)
	
	destring situation, replace 
	replace situation = -1   if situation ==1 
	replace situation = -0.5 if situation ==2
	replace situation = 0    if situation ==3 
	replace situation = -0.5 if situation ==4
	replace situation = 1    if situation ==5	
	
	rename StandardDG_1_n_  StandardDG_0_n_
	rename StandardDG_2_n_  StandardDG_1_n_
	rename StandardDG_3_n_  StandardDG_2_n_
	rename StandardDG_4_n_  StandardDG_3_n_
	rename StandardDG_5_n_  StandardDG_4_n_
	rename StandardDG_6_n_  StandardDG_5_n_
	rename StandardDG_7_n_  StandardDG_6_n_
	rename StandardDG_8_n_  StandardDG_7_n_
	rename StandardDG_9_n_  StandardDG_8_n_
	rename StandardDG_10_n_  StandardDG_9_n_
	rename StandardDG_11_n_  StandardDG_10_n_
		
	local varlist StandardDG_0_n_ StandardDG_1_n_ StandardDG_2_n_ StandardDG_3_n_ StandardDG_4_n_ StandardDG_5_n_ StandardDG_6_n_ StandardDG_7_n_ StandardDG_8_n_ StandardDG_9_n_ StandardDG_10_n_ 
	foreach var in `varlist' {
		gen rel_`var' = `var'/obs_stDG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	

	rename DGtake1_1_n_  DGtake1_m2_n_
	rename DGtake1_2_n_  DGtake1_m1_n_
	rename DGtake1_3_n_  DGtake1_0_n_
	rename DGtake1_4_n_  DGtake1_1_n_
	rename DGtake1_5_n_  DGtake1_2_n_
	rename DGtake1_6_n_  DGtake1_3_n_
	rename DGtake1_7_n_  DGtake1_4_n_
	rename DGtake1_8_n_  DGtake1_5_n_
	rename DGtake1_9_n_  DGtake1_6_n_
	rename DGtake1_10_n_ DGtake1_7_n_
	rename DGtake1_11_n_ DGtake1_8_n_
	rename DGtake1_12_n_ DGtake1_9_n_
	rename DGtake1_13_n_ DGtake1_10_n_
	rename DGtake5_1_n_  DGtake5_m10_n_
	rename DGtake5_2_n_  DGtake5_m9_n_
	rename DGtake5_3_n_  DGtake5_m8_n_
	rename DGtake5_4_n_  DGtake5_m7_n_
	rename DGtake5_5_n_  DGtake5_m6_n_
	rename DGtake5_6_n_  DGtake5_m5_n_
	rename DGtake5_7_n_  DGtake5_m4_n_
	rename DGtake5_8_n_  DGtake5_m3_n_
	rename DGtake5_9_n_  DGtake5_m2_n_
	rename DGtake5_10_n_ DGtake5_m1_n_
	rename DGtake5_11_n_ DGtake5_0_n_
	rename DGtake5_12_n_ DGtake5_1_n_
	rename DGtake5_13_n_ DGtake5_2_n_
	rename DGtake5_14_n_ DGtake5_3_n_
	rename DGtake5_15_n_ DGtake5_4_n_
	rename DGtake5_16_n_ DGtake5_5_n_
	rename DGtake5_17_n_ DGtake5_6_n_
	rename DGtake5_18_n_ DGtake5_7_n_
	rename DGtake5_19_n_ DGtake5_8_n_
	rename DGtake5_20_n_ DGtake5_9_n_
	rename DGtake5_21_n_ DGtake5_10_n_
	
	local varlist   DGtake1_m2_n_ DGtake1_m1_n_ DGtake1_0_n_ DGtake1_1_n_ DGtake1_2_n_ DGtake1_3_n_ DGtake1_4_n_ DGtake1_5_n_ DGtake1_6_n_ DGtake1_7_n_  DGtake1_8_n_ DGtake1_9_n_ DGtake1_10_n_  
	foreach var in `varlist' {
	
		gen rel_`var' = `var'/obs_t1DG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	
	local varlist  DGtake5_m10_n_ DGtake5_m9_n_ DGtake5_m8_n_ DGtake5_m7_n_ DGtake5_m6_n_ DGtake5_m5_n_ DGtake5_m4_n_ DGtake5_m3_n_ DGtake5_m2_n_ DGtake5_m1_n_ DGtake5_0_n_ DGtake5_1_n_ DGtake5_2_n_ DGtake5_3_n_ DGtake5_4_n_ DGtake5_5_n_ DGtake5_6_n_ DGtake5_7_n_  DGtake5_8_n_ DGtake5_9_n_ DGtake5_10_n_ 
		foreach var in `varlist' {
	
		gen rel_`var' = `var'/obs_t5DG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	
	ds mean* hi* low* sd*
		
	#d ; 
	collapse (first) mean_S~_0_n_  mean_~1_5_n_  mean_~5_2_n_  hi_Stan~9_n_  hi_DGt~m7_n_  low_St~_0_n_  low_D~1_5_n_  low_D~5_2_n_  sd_Stan~9_n_  sd_DGt~m7_n_
					mean_St~1_n_  mean_~1_6_n_  mean_~5_3_n_  hi_Sta~10_n_  hi_DGt~m6_n_  low_Sta~1_n_  low_D~1_6_n_  low_D~5_3_n_  sd_Sta~10_n_  sd_DGt~m6_n_
					mean_St~2_n_  mean_~1_7_n_  mean_~5_4_n_  hi_D~1_m2_n_  hi_DGt~m5_n_  low_Sta~2_n_  low_D~1_7_n_  low_D~5_4_n_  sd_D~1_m2_n_  sd_DGt~m5_n_
					mean_St~3_n_  mean_~1_8_n_  mean_~5_5_n_  hi_D~1_m1_n_  hi_DGt~m4_n_  low_Sta~3_n_  low_D~1_8_n_  low_D~5_5_n_  sd_D~1_m1_n_  sd_DGt~m4_n_
					mean_St~4_n_  mean_~1_9_n_  mean_~5_6_n_  hi_DG~1_0_n_  hi_DGt~m3_n_  low_Sta~4_n_  low_D~1_9_n_  low_D~5_6_n_  sd_DG~1_0_n_  sd_DGt~m3_n_
					mean_St~5_n_  mean~1_10_n_  mean_~5_7_n_  hi_DG~1_1_n_  hi_D~5_m2_n_  low_Sta~5_n_  low_~1_10_n_  low_D~5_7_n_  sd_DG~1_1_n_  sd_D~5_m2_n_
					mean_St~6_n_  mean_~m10_n_  mean_~5_8_n_  hi_DG~1_2_n_  hi_D~5_m1_n_  low_Sta~6_n_  low_D~m10_n_  low_D~5_8_n_  sd_DG~1_2_n_  sd_D~5_m1_n_
					mean_St~7_n_  mean_D~m9_n_  mean_~5_9_n_  hi_DG~1_3_n_  hi_DG~5_0_n_  low_Sta~7_n_  low_DG~m9_n_  low_D~5_9_n_  sd_DG~1_3_n_  sd_DG~5_0_n_
					mean_St~8_n_  mean_D~m8_n_  mean~5_10_n_  hi_DG~1_4_n_  hi_DG~5_1_n_  low_Sta~8_n_  low_DG~m8_n_  low_~5_10_n_  sd_DG~1_4_n_  sd_DG~5_1_n_
					mean_St~9_n_  mean_D~m7_n_  hi_Sta~_0_n_  hi_DG~1_5_n_  hi_DG~5_2_n_  low_Sta~9_n_  low_DG~m7_n_  sd_Sta~_0_n_  sd_DG~1_5_n_  sd_DG~5_2_n_
					mean_S~10_n_  mean_D~m6_n_  hi_Stan~1_n_  hi_DG~1_6_n_  hi_DG~5_3_n_  low_St~10_n_  low_DG~m6_n_  sd_Stan~1_n_  sd_DG~1_6_n_  sd_DG~5_3_n_
					mean~1_m2_n_  mean_D~m5_n_  hi_Stan~2_n_  hi_DG~1_7_n_  hi_DG~5_4_n_  low_~1_m2_n_  low_DG~m5_n_  sd_Stan~2_n_  sd_DG~1_7_n_  sd_DG~5_4_n_
					mean~1_m1_n_  mean_D~m4_n_  hi_Stan~3_n_  hi_DG~1_8_n_  hi_DG~5_5_n_  low_~1_m1_n_  low_DG~m4_n_  sd_Stan~3_n_  sd_DG~1_8_n_  sd_DG~5_5_n_
					mean_~1_0_n_  mean_D~m3_n_  hi_Stan~4_n_  hi_DG~1_9_n_  hi_DG~5_6_n_  low_D~1_0_n_  low_DG~m3_n_  sd_Stan~4_n_  sd_DG~1_9_n_  sd_DG~5_6_n_
					mean_~1_1_n_  mean~5_m2_n_  hi_Stan~5_n_  hi_D~1_10_n_  hi_DG~5_7_n_  low_D~1_1_n_  low_~5_m2_n_  sd_Stan~5_n_  sd_D~1_10_n_  sd_DG~5_7_n_
					mean_~1_2_n_  mean~5_m1_n_  hi_Stan~6_n_  hi_DG~m10_n_  hi_DG~5_8_n_  low_D~1_2_n_  low_~5_m1_n_  sd_Stan~6_n_  sd_DG~m10_n_  sd_DG~5_8_n_
					mean_~1_3_n_  mean_~5_0_n_  hi_Stan~7_n_  hi_DGt~m9_n_  hi_DG~5_9_n_  low_D~1_3_n_  low_D~5_0_n_  sd_Stan~7_n_  sd_DGt~m9_n_  sd_DG~5_9_n_
					mean_~1_4_n_  mean_~5_1_n_  hi_Stan~8_n_  hi_DGt~m8_n_  hi_D~5_10_n_  low_D~1_4_n_  low_D~5_1_n_  sd_Stan~8_n_  sd_DGt~m8_n_  sd_D~5_10_n_
						, by(obs_stDG)
						; 
	
	#d cr
	

	reshape long mean_StandardDG_@_n_ sd_StandardDG_@_n_ hi_StandardDG_@_n_ low_StandardDG_@_n_ mean_DGtake1_@_n_ sd_DGtake1_@_n_ hi_DGtake1_@_n_ low_DGtake1_@_n_ mean_DGtake5_@_n_ sd_DGtake5_@_n_ hi_DGtake5_@_n_ low_DGtake5_@_n_ , i(obs_stDG) j(payoff) string
	
	replace payoff = subinstr(payoff, "m", "-", . )
	destring payoff, replace
	sort payoff
	
	graph twoway (line mean_StandardDG__n_ payoff) ||  (rcap  hi_StandardDG__n_ low_StandardDG__n_ payoff, )  ///
	|| (line mean_DGtake1__n_ payoff) || (rcap  hi_DGtake1__n_ low_DGtake1__n_ payoff ) ///
	|| (line mean_DGtake5__n_ payoff) || (rcap  hi_DGtake5__n_ low_DGtake5__n_ payoff) ,  ///
	ytitle("Average rating") title("Standard DG and DG with take 1 and take 5 option") sub("Personal appropriateness") xlabel(#20) ylabel(#5) yscale( r(-1/1)) graphregion(color(white)) bgcolor(white) 	legend(size(vsmall) pos(6)   lab(1 "Standard DG") lab(2 "CI (5% level) St. DG") lab(3 "DG take 1") lab(4 "CI (5% level) DG take 1") lab(5 "DG take 5") lab(6 "CI (5% level) DG take 5") stack) 
	graph export "$mainpath/takeDG_personal.png", replace
	
restore


****				   
* DG with surplus generation
preserve 

	local varlist StandardDG_1_n StandardDG_2_n StandardDG_3_n StandardDG_4_n StandardDG_5_n StandardDG_6_n StandardDG_7_n StandardDG_8_n StandardDG_9_n StandardDG_10_n StandardDG_11_n ///
	    DGQuiz_1_n DGQuiz_2_n DGQuiz_5_n DGQuiz_6_n DGQuiz_7_n DGQuiz_8_n DGQuiz_9_n DGQuiz_10_n DGQuiz_11_n DGProduction_1_n DGProduction_2_n DGProduction_4_n DGProduction_5_n DGProduction_6_n DGProduction_9_n DGProduction_10_n DGProduction_11_n
	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if `var' !=.
		gen `var'_2 = (`var'==-0.5) if `var' !=.
		gen `var'_3 = (`var'==0) if `var' !=.
		gen `var'_4 = (`var'==0.5) if `var' !=.
		gen `var'_5 = (`var'==1)  if `var' !=.
		
	}
	
	gen obs_stDG = _n if StandardDG_1_n !=.
	gen obs_qDG = _n if DGQuiz_1_n !=.
	gen obs_pDG = _n if DGProduction_1_n !=.

	reshape long  StandardDG_1_n_@ StandardDG_2_n_@ StandardDG_3_n_@ StandardDG_4_n_@ StandardDG_5_n_@ StandardDG_6_n_@ StandardDG_7_n_@ StandardDG_8_n_@ StandardDG_9_n_@ StandardDG_10_n_@ StandardDG_11_n_@ ///
	    DGQuiz_1_n_@ DGQuiz_2_n_@ DGQuiz_5_n_@ DGQuiz_6_n_@ DGQuiz_7_n_@ DGQuiz_8_n_@ DGQuiz_9_n_@ DGQuiz_10_n_@ DGQuiz_11_n_@ DGProduction_1_n_@ DGProduction_2_n_@ DGProduction_4_n_@ DGProduction_5_n_@ DGProduction_6_n_@ DGProduction_9_n_@ DGProduction_10_n_@ DGProduction_11_n_@ , i(participant_id) j(situation) string 
	
	collapse (count)  obs_stDG obs_qDG obs_pDG (sum) StandardDG_1_n_ StandardDG_2_n_ StandardDG_3_n_ StandardDG_4_n_ StandardDG_5_n_ StandardDG_6_n_ StandardDG_7_n_ StandardDG_8_n_ StandardDG_9_n_ StandardDG_10_n_ StandardDG_11_n_  DGQuiz_1_n_ DGQuiz_2_n_ DGQuiz_5_n_ DGQuiz_6_n_ DGQuiz_7_n_ DGQuiz_8_n_ DGQuiz_9_n_ DGQuiz_10_n_ DGQuiz_11_n_ DGProduction_1_n_ DGProduction_2_n_ DGProduction_4_n_ DGProduction_5_n_ DGProduction_6_n_ DGProduction_9_n_ DGProduction_10_n_ DGProduction_11_n_ , by(situation)
	
	destring situation, replace 
	replace situation = -1   if situation ==1 
	replace situation = -0.5 if situation ==2
	replace situation = 0    if situation ==3 
	replace situation = -0.5 if situation ==4
	replace situation = 1    if situation ==5	
	

		
	local varlist StandardDG_11_n_ StandardDG_1_n_ StandardDG_2_n_ StandardDG_3_n_ StandardDG_4_n_ StandardDG_5_n_ StandardDG_6_n_ StandardDG_7_n_ StandardDG_8_n_ StandardDG_9_n_ StandardDG_10_n_ 
	foreach var in `varlist' {
		gen rel_`var' = `var'/obs_stDG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	
	
	local varlist   DGQuiz_1_n_ DGQuiz_2_n_ DGQuiz_5_n_ DGQuiz_6_n_ DGQuiz_7_n_ DGQuiz_8_n_ DGQuiz_9_n_ DGQuiz_10_n_ DGQuiz_11_n_ 
	foreach var in `varlist' {
	
		gen rel_`var' = `var'/obs_qDG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	
	local varlist  DGProduction_1_n_ DGProduction_2_n_ DGProduction_4_n_ DGProduction_5_n_ DGProduction_6_n_ DGProduction_9_n_ DGProduction_10_n_ DGProduction_11_n_ 
		foreach var in `varlist' {
	
		gen rel_`var' = `var'/obs_pDG
		sum situation [weight = rel_`var']
		gen mean_`var' = r(mean)
		gen sd_`var' = r(sd)
		gen hi_`var'  = mean_`var' + (1.96*sd_`var')
		gen low_`var' = mean_`var' - (1.96*sd_`var')
		order mean_`var' sd_`var' hi_`var' low_`var', after(`var')
	}
	
	ds mean* hi* low* sd*
		
	#d ; 
	collapse (first) mean_S~_1_n_  mean_~z_2_n_  mean_~n_6_n_  hi_Stan~9_n_  hi_DGP~_1_n_  low_Sta~5_n_  low_DGQ~8_n_  sd_Sta~_1_n_  sd_DGQu~2_n_  sd_DGPr~6_n_
					mean_St~2_n_  mean_~z_5_n_  mean_~n_9_n_  hi_Stan~0_n_  hi_DGPr~2_n_  low_Sta~6_n_  low_DGQ~9_n_  sd_Stan~2_n_  sd_DGQu~5_n_  sd_DGPr~9_n_
					mean_St~3_n_  mean_~z_6_n_  mean~n_10_n_  hi_Sta~11_n_  hi_DGPr~4_n_  low_Sta~7_n_  low_DGQ~0_n_  sd_Stan~3_n_  sd_DGQu~6_n_  sd_DGPr~0_n_
					mean_St~4_n_  mean_DG~7_n_  mean~n_11_n_  hi_DGQ~_1_n_  hi_DGPr~5_n_  low_Sta~8_n_  low_~z_11_n_  sd_Stan~4_n_  sd_DGQu~7_n_  sd_DGP~11_n_
					mean_St~5_n_  mean_DG~8_n_  hi_Sta~_1_n_  hi_DGQu~2_n_  hi_DGPr~6_n_  low_Sta~9_n_  low_D~n_1_n_  sd_Stan~5_n_  sd_DGQu~8_n_
					mean_St~6_n_  mean_~z_9_n_  hi_Stan~2_n_  hi_DGQu~5_n_  hi_DGPr~9_n_  low_Sta~0_n_  low_DGP~2_n_  sd_Stan~6_n_  sd_DGQu~9_n_
					mean_St~7_n_  mean~z_10_n_  hi_Stan~3_n_  hi_DGQu~6_n_  hi_DGPr~0_n_  low_St~11_n_  low_DGP~4_n_  sd_Stan~7_n_  sd_DGQu~0_n_
					mean_St~8_n_  mean~z_11_n_  hi_Stan~4_n_  hi_DGQu~7_n_  hi_DGP~11_n_  low_D~z_1_n_  low_DGP~5_n_  sd_Stan~8_n_  sd_DGQ~11_n_
					mean_St~9_n_  mean_~n_1_n_  hi_Stan~5_n_  hi_DGQu~8_n_  low_St~_1_n_  low_DGQ~2_n_  low_DGP~6_n_  sd_Stan~9_n_  sd_DGP~_1_n_
					mean_St~0_n_  mean_~n_2_n_  hi_Stan~6_n_  hi_DGQu~9_n_  low_Sta~2_n_  low_DGQ~5_n_  low_DGP~9_n_  sd_Stan~0_n_  sd_DGPr~2_n_
					mean_S~11_n_  mean_DG~4_n_  hi_Stan~7_n_  hi_DGQu~0_n_  low_Sta~3_n_  low_DGQ~6_n_  low_DGP~0_n_  sd_Sta~11_n_  sd_DGPr~4_n_
					mean_~z_1_n_  mean_~n_5_n_  hi_Stan~8_n_  hi_DGQ~11_n_  low_Sta~4_n_  low_DGQ~7_n_  low_~n_11_n_  sd_DGQ~_1_n_  sd_DGPr~5_n_
						, by(obs_stDG)
						; 
	
	#d cr
	

	reshape long mean_StandardDG_@_n_ sd_StandardDG_@_n_ hi_StandardDG_@_n_ low_StandardDG_@_n_ mean_DGQuiz_@_n_ sd_DGQuiz_@_n_ hi_DGQuiz_@_n_ low_DGQuiz_@_n_ mean_DGProduction_@_n_ sd_DGProduction_@_n_ hi_DGProduction_@_n_ low_DGProduction_@_n_ , i(obs_stDG) j(payoff) 
	
	replace payoff = payoff-1
	
	
	graph twoway (line mean_StandardDG__n_ payoff) ||  (rcap  hi_StandardDG__n_ low_StandardDG__n_ payoff, )  ///
	|| (line mean_DGQuiz__n_ payoff) || (rcap  hi_DGQuiz__n_ low_DGQuiz__n_ payoff ) ///
	|| (line mean_DGProduction__n_ payoff) || (rcap  hi_DGProduction__n_ low_DGProduction__n_ payoff) ,  ///
	ytitle("Average rating") title("Standard DG and DG with take 1 and take 5 option") sub("Personal appropriateness") xlabel(#20) ylabel(#5) yscale( r(-1/1)) graphregion(color(white)) bgcolor(white) 	legend(size(vsmall) pos(6)   lab(1 "Standard DG") lab(2 "CI (5% level) St. DG") lab(3 "DG quiz") lab(4 "CI (5% level) DG quiz") lab(5 "DG production") lab(6 "CI (5% level) DG production") stack) 
	graph export "$mainpath/surplusDG_personal.png", replace
	
restore	
	

** END	

clear all


/* Paste code from Figures_crowd.do here */
global mainpath "/Users/petterhallqvist/Desktop/tore_ellingsen/crowding_multiple_games_combined"
cd "$mainpath"

*------------------------------------------------------------------------------*
						
						*-------------------*
						*       FIGURES     *
						*-------------------*


use "$mainpath/5scale_BEARB_merged_cleaned.dta", clear 


                   ** SOCIAL APPROPRIATENESS **
				   
* LOST WALLET SITUATION 
preserve

	local varlist Walletnomoney_1_n Walletnomoney_2_n Walletsmallmoney_1_n Walletsmallmoney_2_n Walletbigmoney_1_n Walletbigmoney_2_n
	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if Condition =="1"
		gen `var'_2 = (`var'==-0.5) if Condition =="1"
		gen `var'_3 = (`var'==0) if Condition =="1"
		gen `var'_4 = (`var'==0.5) if Condition =="1"
		gen `var'_5 = (`var'==1) if Condition =="1"
		
	}
	
	gen obs = _n if Condition =="1"
	reshape long Wallet@_1_n_1 Wallet@_2_n_1 Wallet@_1_n_2 Wallet@_2_n_2 Wallet@_1_n_3 Wallet@_2_n_3 Wallet@_1_n_4 Wallet@_2_n_4 Wallet@_1_n_5 Wallet@_2_n_5, i(participant_id) j(situation) string
	collapse (count) obs (sum) Wallet_1_n_1 Wallet_1_n_2 Wallet_1_n_3 Wallet_1_n_4 Wallet_1_n_5 Wallet_2_n_1 Wallet_2_n_2 Wallet_2_n_3 Wallet_2_n_4 Wallet_2_n_5, by(situation)
	
	local varlist_wallet Wallet_1_n_1 Wallet_1_n_2 Wallet_1_n_3 Wallet_1_n_4 Wallet_1_n_5 Wallet_2_n_1 Wallet_2_n_2 Wallet_2_n_3 Wallet_2_n_4 Wallet_2_n_5
	foreach var in `varlist_wallet' {
		replace `var' = `var'/obs
	}

	
	reshape long Wallet_1_n_@  Wallet_2_n_@, i(situation) j(ranking) 
	#d ;
	label define ranking 1 "VSI"
	                     2 "SSI"
	                     3 "N"
	                     4 "SSA"
	                     5 "VSA", 
						 replace 
						 ; 
	#d cr 
	
	label val ranking ranking
	
	graph bar (mean) Wallet_1_n_ , over(situation) over(ranking) /// 
	title("Not returning wallet")  sub("5 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/wallet_1_5.png", replace
	
	graph bar (mean) Wallet_2_n_ , over(situation) over(ranking) ///
	title("Returning wallet")  sub("5 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/wallet_2_5.png", replace
	
restore
	
	
* DAY CARE SITUATION
preserve

	local varlist Daycarenofine_1_n Daycarenofine_2_n Daycarenofine_3_n Daycaresmallfine_1_n Daycaresmallfine_2_n Daycaresmallfine_3_n Daycarebigfine_1_n Daycarebigfine_2_n Daycarebigfine_3_n
	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if Condition =="1"
		gen `var'_2 = (`var'==-0.5) if Condition =="1"
		gen `var'_3 = (`var'==0) if Condition =="1"
		gen `var'_4 = (`var'==0.5) if Condition =="1"
		gen `var'_5 = (`var'==1) if Condition =="1"
		
	}
	
	gen obs = _n if Condition =="1"
	reshape long Daycare@_1_n_1 Daycare@_1_n_2 Daycare@_1_n_3 Daycare@_1_n_4 Daycare@_1_n_5  Daycare@_2_n_1 Daycare@_2_n_2 Daycare@_2_n_3 Daycare@_2_n_4 Daycare@_2_n_5 Daycare@_3_n_1  Daycare@_3_n_2 Daycare@_3_n_3 Daycare@_3_n_4 Daycare@_3_n_5, i(participant_id) j(situation) string
	
	replace situation= "No fine" if situation == "nomoney"
	replace situation= "Small fine" if situation == "smallfine"	
	replace situation= "Big fine" if situation == "bigfine"	
	
	collapse (count) obs (sum) Daycare_1_n_1 Daycare_1_n_2 Daycare_1_n_3 Daycare_1_n_4 Daycare_1_n_5 Daycare_2_n_1 Daycare_2_n_2 Daycare_2_n_3 Daycare_2_n_4 Daycare_2_n_5 Daycare_3_n_1 Daycare_3_n_2 Daycare_3_n_3 Daycare_3_n_4 Daycare_3_n_5, by(situation)
	
	local varlist_daycare Daycare_1_n_1 Daycare_1_n_2 Daycare_1_n_3 Daycare_1_n_4 Daycare_1_n_5 Daycare_2_n_1 Daycare_2_n_2 Daycare_2_n_3 Daycare_2_n_4 Daycare_2_n_5 Daycare_3_n_1 Daycare_3_n_2 Daycare_3_n_3 Daycare_3_n_4 Daycare_3_n_5
	foreach var in `varlist_daycare' {
		replace `var' = `var'/obs
	}

	
	reshape long Daycare_1_n_@  Daycare_2_n_@ Daycare_3_n_@, i(situation) j(ranking) 
	#d ;
	label define ranking 1 "VSI"
	                     2 "SSI"
	                     3 "N"
	                     4 "SSA"
	                     5 "VSA", 
						 replace 
						 ; 
	#d cr 
	
	label val ranking ranking
	
	graph bar (mean) Daycare_1_n_ , over(situation) over(ranking) /// 
	title("On time")  sub("5 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/daycare_1_5.png", replace
	
	graph bar (mean) Daycare_2_n_ , over(situation) over(ranking) ///
	title("15 mins late")  sub("5 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/daycare_2_5.png", replace
	
	graph bar (mean) Daycare_3_n_ , over(situation) over(ranking) ///
	title("30 mins late")  sub("5 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/daycare_3_5.png", replace
	
restore

						** PERSONAL  APPROPRIATENESS **

* LOST WALLET SITUATION 
preserve

	local varlist Q49_1_n Q49_2_n Q50_1_n Q50_2_n Q51_1_n Q51_2_n
	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if Condition =="2"
		gen `var'_2 = (`var'==-0.5) if Condition =="2"
		gen `var'_3 = (`var'==0) if Condition =="2"
		gen `var'_4 = (`var'==0.5) if Condition =="2"
		gen `var'_5 = (`var'==1) if Condition =="2"
		
	}
	
	gen obs = _n if Condition =="2"
	reshape long Q@_1_n_1 Q@_2_n_1 Q@_1_n_2 Q@_2_n_2 Q@_1_n_3 Q@_2_n_3 Q@_1_n_4 Q@_2_n_4 Q@_1_n_5 Q@_2_n_5, i(participant_id) j(situation) string
	
	replace situation= "No money" if situation == "49"
	replace situation= "Small money" if situation == "50"	
	replace situation= "Big money" if situation == "51"	
	
	collapse (count) obs (sum) Q_1_n_1 Q_1_n_2 Q_1_n_3 Q_1_n_4 Q_1_n_5 Q_2_n_1 Q_2_n_2 Q_2_n_3 Q_2_n_4 Q_2_n_5, by(situation)
	
	local varlist_wallet Q_1_n_1 Q_1_n_2 Q_1_n_3 Q_1_n_4 Q_1_n_5 Q_2_n_1 Q_2_n_2 Q_2_n_3 Q_2_n_4 Q_2_n_5
	foreach var in `varlist_wallet' {
		replace `var' = `var'/obs
	}

	
	reshape long Q_1_n_@  Q_2_n_@, i(situation) j(ranking) 
	#d ;
	label define ranking 1 "VI"
	                     2 "SI"
	                     3 "N"
	                     4 "SA"
	                     5 "VA", 
						 replace 
						 ; 
	#d cr 
	
	label val ranking ranking
	
	graph bar (mean) Q_1_n_ , over(situation) over(ranking) /// 
	title("Not returning wallet")  sub("5 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/wallet_1_5_personal.png", replace
	
	graph bar (mean) Q_2_n_ , over(situation) over(ranking) ///
	title("Returning wallet")  sub("5 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/wallet_2_5_personal.png", replace
	
restore
	
	
* DAY CARE SITUATION
preserve

	local varlist Q52_1_n Q52_2_n Q52_3_n Q53_1_n Q53_2_n Q53_3_n Q54_1_n Q54_2_n Q54_3_n
	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if Condition =="2"
		gen `var'_2 = (`var'==-0.5) if Condition =="2"
		gen `var'_3 = (`var'==0) if Condition =="2"
		gen `var'_4 = (`var'==0.5) if Condition =="2"
		gen `var'_5 = (`var'==1) if Condition =="2"
		
	}
	
	gen obs = _n if Condition =="2"
	reshape long Q5@_1_n_1 Q5@_1_n_2 Q5@_1_n_3 Q5@_1_n_4 Q5@_1_n_5  Q5@_2_n_1 Q5@_2_n_2 Q5@_2_n_3 Q5@_2_n_4 Q5@_2_n_5 Q5@_3_n_1  Q5@_3_n_2 Q5@_3_n_3 Q5@_3_n_4 Q5@_3_n_5, i(participant_id) j(situation) string
	
	replace situation= "No fine" if situation == "2"
	replace situation= "Small fine" if situation == "3"	
	replace situation= "Big money" if situation == "4"	
	
	collapse (count) obs (sum) Q5_1_n_1 Q5_1_n_2 Q5_1_n_3 Q5_1_n_4 Q5_1_n_5 Q5_2_n_1 Q5_2_n_2 Q5_2_n_3 Q5_2_n_4 Q5_2_n_5 Q5_3_n_1 Q5_3_n_2 Q5_3_n_3 Q5_3_n_4 Q5_3_n_5, by(situation)
	
	local varlist_daycare Q5_1_n_1 Q5_1_n_2 Q5_1_n_3 Q5_1_n_4 Q5_1_n_5 Q5_2_n_1 Q5_2_n_2 Q5_2_n_3 Q5_2_n_4 Q5_2_n_5 Q5_3_n_1 Q5_3_n_2 Q5_3_n_3 Q5_3_n_4 Q5_3_n_5
	foreach var in `varlist_daycare' {
		replace `var' = `var'/obs
	}

	
	reshape long Q5_1_n_@  Q5_2_n_@ Q5_3_n_@, i(situation) j(ranking) 
	#d ;
	label define ranking 1 "VI"
	                     2 "SI"
	                     3 "N"
	                     4 "SA"
	                     5 "VA" ,
						 replace 
						 ; 
	#d cr 
	
	label val ranking ranking
	
	graph bar (mean) Q5_1_n_ , over(situation) over(ranking) /// 
	title("On time")  sub("5 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/daycare_1_5_personal.png", replace
	
	graph bar (mean) Q5_2_n_ , over(situation) over(ranking) ///
	title("15 mins late")  sub("5 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/daycare_2_5_personal.png", replace
	
	graph bar (mean) Q5_3_n_ , over(situation) over(ranking) ///
	title("30 mins late")  sub("5 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/daycare_3_5_personal.png", replace
	
restore


*******************************************************************************
*************************** 7 SCALE *******************************************
*******************************************************************************

use "$mainpath/7scale_BEARB_merged_cleaned.dta", clear  


                   ** SOCIAL APPROPRIATENESS **
				   
* LOST WALLET SITUATION 
preserve

	local varlist Walletnomoney_1_n Walletnomoney_2_n Walletsmallmoney_1_n Walletsmallmoney_2_n Walletbigmoney_1_n Walletbigmoney_2_n
	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if Condition =="1"
		gen `var'_2 = (`var'< -0.5 & `var'> -1) if Condition =="1"
		gen `var'_3 = (`var'< 0 &  `var'> -0.5) if  Condition =="1"
		gen `var'_4 = (`var'==0) if Condition =="1"
		gen `var'_5 = (`var'< 0.5 & `var'> 0) if  Condition =="1"
		gen `var'_6 = (`var'< 1 & `var'> 0.5) if  Condition =="1"
		gen `var'_7 = (`var'==1) if Condition =="1"
		
	}
	
	gen obs = _n if Condition =="1"
	reshape long Wallet@_1_n_1 Wallet@_2_n_1 Wallet@_1_n_2 Wallet@_2_n_2 Wallet@_1_n_3 Wallet@_2_n_3 Wallet@_1_n_4 Wallet@_2_n_4 Wallet@_1_n_5 Wallet@_2_n_5 Wallet@_1_n_6 Wallet@_2_n_6 Wallet@_1_n_7 Wallet@_2_n_7, i(participant_id) j(situation) string
	collapse (count) obs (sum) Wallet_1_n_1 Wallet_1_n_2 Wallet_1_n_3 Wallet_1_n_4 Wallet_1_n_5 Wallet_1_n_6 Wallet_1_n_7 Wallet_2_n_1 Wallet_2_n_2 Wallet_2_n_3 Wallet_2_n_4 Wallet_2_n_5 Wallet_2_n_6 Wallet_2_n_7, by(situation)
	
	local varlist_wallet Wallet_1_n_1 Wallet_1_n_2 Wallet_1_n_3 Wallet_1_n_4 Wallet_1_n_5 Wallet_1_n_6 Wallet_1_n_7 Wallet_2_n_1 Wallet_2_n_2 Wallet_2_n_3 Wallet_2_n_4 Wallet_2_n_5 Wallet_2_n_6 Wallet_2_n_7
	foreach var in `varlist_wallet' {
		replace `var' = `var'/obs
	}

	
	reshape long Wallet_1_n_@  Wallet_2_n_@, i(situation) j(ranking) 
	#d ;
	label define ranking 1 "VSI"
	                     2 "SI"
						 3 "SSI"
	                     4 "N"
	                     5 "SSA"
						 6 "SA"
	                     7 "VSA",
 
						 replace 
						 ; 
	#d cr 
	
	label val ranking ranking
	
	graph bar (mean) Wallet_1_n_ , over(situation) over(ranking) /// 
	title("Not returning wallet")  sub("7 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/wallet_1_7.png", replace
	
	graph bar (mean) Wallet_2_n_ , over(situation) over(ranking) ///
	title("Returning wallet")  sub("7 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/wallet_2_7.png", replace
	
restore
	
	
* DAY CARE SITUATION
preserve

	local varlist Daycarenofine_1_n Daycarenofine_2_n Daycarenofine_3_n Daycaresmallfine_1_n Daycaresmallfine_2_n Daycaresmallfine_3_n Daycarebigfine_1_n Daycarebigfine_2_n Daycarebigfine_3_n
	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if Condition =="1"
		gen `var'_2 = (`var'< -0.5 & `var'> -1) if Condition =="1"
		gen `var'_3 = (`var'< 0 &  `var'> -0.5) if  Condition =="1"
		gen `var'_4 = (`var'==0) if Condition =="1"
		gen `var'_5 = (`var'< 0.5 & `var'> 0) if  Condition =="1"
		gen `var'_6 = (`var'< 1 & `var'> 0.5) if  Condition =="1"
		gen `var'_7 = (`var'==1) if Condition =="1"
		
	}
	
	gen obs = _n if Condition =="1"
	reshape long Daycare@_1_n_1 Daycare@_1_n_2 Daycare@_1_n_3 Daycare@_1_n_4 Daycare@_1_n_5  Daycare@_1_n_6 Daycare@_1_n_7 Daycare@_2_n_1 Daycare@_2_n_2 Daycare@_2_n_3 Daycare@_2_n_4 Daycare@_2_n_5 Daycare@_2_n_6 Daycare@_2_n_7 Daycare@_3_n_1  Daycare@_3_n_2 Daycare@_3_n_3 Daycare@_3_n_4 Daycare@_3_n_5 Daycare@_3_n_6 Daycare@_3_n_7, i(participant_id) j(situation) string
	
	replace situation= "No fine" if situation == "nomoney"
	replace situation= "Small fine" if situation == "smallfine"	
	replace situation= "Big fine" if situation == "bigfine"	
	
	collapse (count) obs (sum) Daycare_1_n_1 Daycare_1_n_2 Daycare_1_n_3 Daycare_1_n_4 Daycare_1_n_5 Daycare_1_n_6 Daycare_1_n_7 Daycare_2_n_1 Daycare_2_n_2 Daycare_2_n_3 Daycare_2_n_4 Daycare_2_n_5 Daycare_2_n_6 Daycare_2_n_7 Daycare_3_n_1 Daycare_3_n_2 Daycare_3_n_3 Daycare_3_n_4 Daycare_3_n_5 Daycare_3_n_6 Daycare_3_n_7, by(situation)
	
	local varlist_daycare Daycare_1_n_1 Daycare_1_n_2 Daycare_1_n_3 Daycare_1_n_4 Daycare_1_n_5 Daycare_1_n_6 Daycare_1_n_7 Daycare_2_n_1 Daycare_2_n_2 Daycare_2_n_3 Daycare_2_n_4 Daycare_2_n_5 Daycare_2_n_6 Daycare_2_n_7 Daycare_3_n_1 Daycare_3_n_2 Daycare_3_n_3 Daycare_3_n_4 Daycare_3_n_5 Daycare_3_n_6 Daycare_3_n_7
	foreach var in `varlist_daycare' {
		replace `var' = `var'/obs
	}

	
	reshape long Daycare_1_n_@  Daycare_2_n_@ Daycare_3_n_@, i(situation) j(ranking) 
	#d ;
	label define ranking 1 "VSI"
	                     2 "SI"
						 3 "SSI"
	                     4 "N"
	                     5 "SSA"
						 6 "SA"
	                     7 "VSA",
						 replace 
						 ; 
	#d cr 
	
	label val ranking ranking
	
	graph bar (mean) Daycare_1_n_ , over(situation) over(ranking) /// 
	title("On time")  sub("7 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/daycare_1_7.png", replace
	
	graph bar (mean) Daycare_2_n_ , over(situation) over(ranking) ///
	title("15 mins late")  sub("7 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/daycare_2_7.png", replace
	
	graph bar (mean) Daycare_3_n_ , over(situation) over(ranking) ///
	title("30 mins late")  sub("7 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/daycare_3_7.png", replace
	
restore

						** PERSONAL  APPROPRIATENESS **

* LOST WALLET SITUATION 
preserve

	local varlist Q49_1_n Q49_2_n Q50_1_n Q50_2_n Q51_1_n Q51_2_n
	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if Condition =="2"
		gen `var'_2 = (`var'< -0.5 & `var'> -1) if Condition =="2"
		gen `var'_3 = (`var'< 0 &  `var'> -0.5) if  Condition =="2"
		gen `var'_4 = (`var'==0) if Condition =="2"
		gen `var'_5 = (`var'< 0.5 & `var'> 0) if  Condition =="2"
		gen `var'_6 = (`var'< 1 & `var'> 0.5) if  Condition =="2"
		gen `var'_7 = (`var'==1) if Condition =="2"
		
	}
	
	gen obs = _n if Condition =="2"
	reshape long Q@_1_n_1 Q@_2_n_1 Q@_1_n_2 Q@_2_n_2 Q@_1_n_3 Q@_2_n_3 Q@_1_n_4 Q@_2_n_4 Q@_1_n_5 Q@_2_n_5 Q@_1_n_6 Q@_2_n_6 Q@_1_n_7 Q@_2_n_7, i(participant_id) j(situation) string
	
	replace situation= "No money" if situation == "49"
	replace situation= "Small money" if situation == "50"	
	replace situation= "Big money" if situation == "51"	
	
	collapse (count) obs (sum) Q_1_n_1 Q_1_n_2 Q_1_n_3 Q_1_n_4 Q_1_n_5 Q_1_n_6 Q_1_n_7 Q_2_n_1 Q_2_n_2 Q_2_n_3 Q_2_n_4 Q_2_n_5 Q_2_n_6 Q_2_n_7, by(situation)
	
	local varlist_wallet Q_1_n_1 Q_1_n_2 Q_1_n_3 Q_1_n_4 Q_1_n_5 Q_1_n_6 Q_1_n_7 Q_2_n_1 Q_2_n_2 Q_2_n_3 Q_2_n_4 Q_2_n_5 Q_2_n_6 Q_2_n_7
	foreach var in `varlist_wallet' {
		replace `var' = `var'/obs
	}

	
	reshape long Q_1_n_@  Q_2_n_@, i(situation) j(ranking) 
	#d ;
	label define ranking 1 "VSI"
	                     2 "SI"
						 3 "SSI"
	                     4 "N"
	                     5 "SSA"
						 6 "SA"
	                     7 "VSA",
						 replace 
						 ; 
	#d cr 
	
	label val ranking ranking
	
	graph bar (mean) Q_1_n_ , over(situation) over(ranking) /// 
	title("Not returning wallet")  sub("7 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/wallet_1_7_personal.png", replace
	
	graph bar (mean) Q_2_n_ , over(situation) over(ranking) ///
	title("Returning wallet")  sub("7 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/wallet_2_7_personal.png", replace
	
restore
	
	
* DAY CARE SITUATION
preserve

	local varlist Q52_1_n Q52_2_n Q52_3_n Q53_1_n Q53_2_n Q53_3_n Q54_1_n Q54_2_n Q54_3_n
	foreach var in `varlist' {
		
		gen `var'_1 = (`var'==-1) if Condition =="2"
		gen `var'_2 = (`var'< -0.5 & `var'> -1) if Condition =="2"
		gen `var'_3 = (`var'< 0 &  `var'> -0.5) if  Condition =="2"
		gen `var'_4 = (`var'==0) if Condition =="2"
		gen `var'_5 = (`var'< 0.5 & `var'> 0) if  Condition =="2"
		gen `var'_6 = (`var'< 1 & `var'> 0.5) if  Condition =="2"
		gen `var'_7 = (`var'==1) if Condition =="2"
		
	}
	
	gen obs = _n if Condition =="2"
	reshape long Q5@_1_n_1 Q5@_1_n_2 Q5@_1_n_3 Q5@_1_n_4 Q5@_1_n_5  Q5@_1_n_6 Q5@_1_n_7 Q5@_2_n_1 Q5@_2_n_2 Q5@_2_n_3 Q5@_2_n_4 Q5@_2_n_5 Q5@_2_n_6 Q5@_2_n_7 Q5@_3_n_1  Q5@_3_n_2 Q5@_3_n_3 Q5@_3_n_4 Q5@_3_n_5 Q5@_3_n_6 Q5@_3_n_7, i(participant_id) j(situation) string
	
	replace situation= "No fine" if situation == "2"
	replace situation= "Small fine" if situation == "3"	
	replace situation= "Big money" if situation == "4"	
	
	collapse (count) obs (sum) Q5_1_n_1 Q5_1_n_2 Q5_1_n_3 Q5_1_n_4 Q5_1_n_5 Q5_1_n_6 Q5_1_n_7 Q5_2_n_1 Q5_2_n_2 Q5_2_n_3 Q5_2_n_4 Q5_2_n_5 Q5_2_n_6 Q5_2_n_7 Q5_3_n_1 Q5_3_n_2 Q5_3_n_3 Q5_3_n_4 Q5_3_n_5 Q5_3_n_6 Q5_3_n_7, by(situation)
	
	local varlist_daycare Q5_1_n_1 Q5_1_n_2 Q5_1_n_3 Q5_1_n_4 Q5_1_n_5 Q5_1_n_6 Q5_1_n_7 Q5_2_n_1 Q5_2_n_2 Q5_2_n_3 Q5_2_n_4 Q5_2_n_5 Q5_2_n_6 Q5_2_n_7 Q5_3_n_1 Q5_3_n_2 Q5_3_n_3 Q5_3_n_4 Q5_3_n_5 Q5_3_n_6 Q5_3_n_7
	foreach var in `varlist_daycare' {
		replace `var' = `var'/obs
	}

	
	reshape long Q5_1_n_@  Q5_2_n_@ Q5_3_n_@, i(situation) j(ranking) 
	#d ;
	label define ranking 1 "VSI"
	                     2 "SI"
						 3 "SSI"
	                     4 "N"
	                     5 "SSA"
						 6 "SA"
	                     7 "VSA",
						 replace 
						 ; 
	#d cr 
	
	label val ranking ranking
	
	graph bar (mean) Q5_1_n_ , over(situation) over(ranking) /// 
	title("On time")  sub("7 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/daycare_1_7_personal.png", replace
	
	graph bar (mean) Q5_2_n_ , over(situation) over(ranking) ///
	title("15 mins late")  sub("7 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/daycare_2_7_personal.png", replace
	
	graph bar (mean) Q5_3_n_ , over(situation) over(ranking) ///
	title("30 mins late")  sub("7 scale raking") ytitle("%") plotregion(fcolor(white)) graphregion(fcolor(white)) asyvars
	graph export "$mainpath/daycare_3_7_personal.png", replace
	
restore


/****************************************************************************
 * 3. Wrap-Up
 ****************************************************************************/
di as txt "All done! Analysis and Figures produced."
exit, clear
